#安装编译好的NCURSES库
另外,在makemenuconfig过程中也会有一些选项需要你来设置*, y, n或者m,选择*表示选项中的内容被直接编入内核中,选择m表示选项中的内容不编入内核,而只是编成独立的module,用到时才调用。
ok,在当前文件路径下,输入命令:
make menuconfig(或者用 makexconfig,我没有启用成功)
根据菜单提示,选择编译配置选项,并保存配置文件为.config(也可以直接复制现有的.config文件,我是这样做的!!!)
3,确定依赖性
根据以往的经验,这一步是必须的,但是这次编译的时候,系统提醒我没必须要执行这个命令:
make dep
如果用现有的.config文件,这里会有很多内核新增加的驱动和功能让你确认是否编入内核中,这个你就自己看着输入y/n/m/?吧!
4,清除编译中间文件
输入命令:make clean
5,生成新内核(这是我用的时间07:38-07:57,19分钟。这里时间的长短都取决于你机器的性能)
就是把配置过程中,我们选中编入内核中的程序编译链接生产linux内核,输入命令:
make bzImage
6,生成modules(这是我用的时间07:58-09:28)
和上步差不多,就是把配置过程中,我们选中编成modules的程序编译链接成modules,输入命令:
make modules
7,安装modules
就是把刚才编译生产的modules拷到系统文件夹下,以供新内核调用。输入命令:
make modules_install
一切都自动做好了。
8,建立要载入ramdisk的映像文件
如果linux系统安装在scsi磁盘上,这步是必须的,否则可以跳过。我的linux是装在vmware上的,用的是虚拟的scsi磁盘,所以必须要这一步。输入命令:
sudo apt-get installmkinitramfs
如果你的linux不是ubuntu,而是其他的发行版本,那么使用的命令可能不是mkinitramfs,而是mkinitrd,但功能和用法类似。
mkinitramfs -o/boot/initrd-linux3.3.4.img 3.3.4
9,按装内核
输入命令:make install
此时系统会把linux内核的镜像文件还有System.map考入到/boot下,然后会自动生成引导菜单。
10, 配置grub引导程序
既然新的内核编译并安装好了,那么我们要配置系统的引导程序用新内核正确引导,这一步我的是自动添加的,如果没有自动添加进去就自动动手修改添加吧。对象是/boot/grub/grub.cfg,首先用chmod更改该文件的只读属性。然后参照里面的已有内容添加一个新启动项,我的新启动项是:
menuentry 'Ubuntu,Linux 3.3.4' --class ubuntu --class gnu-linux--class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=rootee7c3a4d-5305-46b1-807e-fa9f39a5d13e
linux /boot/vmlinuz-3.3.4root=UUID=ee7c3a4d-5305-46b1-807e-fa9f39a5d13e ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.3.4
}
menuentry 'Ubuntu,Linux 3.3.4 (恢复模式)' --class ubuntu --classgnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=rootee7c3a4d-5305-46b1-807e-fa9f39a5d13e
echo '载入 Linux 3.3.4 ...'
linux /boot/vmlinuz-3.3.4root=UUID=ee7c3a4d-5305-46b1-807e-fa9f39a5d13e ro recoverynomodeset
echo '载入初始化内存盘...'
initrd /boot/initrd.img-3.3.4
}
submenu "Previous Linux versions" {
menuentry 'Ubuntu,Linux 3.2.0-24-generic-pae' --class ubuntu--class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=rootee7c3a4d-5305-46b1-807e-fa9f39a5d13e
linux /boot/vmlinuz-3.2.0-24-generic-paeroot=UUID=ee7c3a4d-5305-46b1-807e-fa9f39a5d13e ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.2.0-24-generic-pae
}
menuentry 'Ubuntu,Linux 3.2.0-24-generic-pae (恢复模式)' --class ubuntu--class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=rootee7c3a4d-5305-46b1-807e-fa9f39a5d13e
echo '载入 Linux3.2.0-24-generic-pae ...'
linux /boot/vmlinuz-3.2.0-24-generic-paeroot=UUID=ee7c3a4d-5305-46b1-807e-fa9f39a5d13e ro recoverynomodeset
echo '载入初始化内存盘...'
initrd /boot/initrd.img-3.2.0-24-generic-pae
}
默认是从新内核镜像启动系统。
万事ok,敲下reboot,系统启动后,从grub菜单中选中新内核引导linux,怎么样,系统启动的鼓声响了吧!
进入后用uname -a看看是否新内核。
11、删除旧内核文件
1,查看一下当前内核版本:uname -a
2.查看一下当前系统内的所有内核文件:dpkg --get-selections|grep linux
3.删除内核文件:
sudo apt-get remove linux-image-3.2.0-24*sudo apt-get removelinux-headers-3.2.0-24*或(删除当前版本之外的所有内核)sudo apt-get purge~ilinux-image-.*\(\!`uname -r`\)
4.另外一条命令:
sudo aptitude purge ~ilinux-image-*\(\!'uname -r'\)
这样就成功删除了,重启一下看看是不是没有那些没用的内核启动项了。
完工!