編譯安裝linux-5.07內核
一、下載內核
至內核官方網站下載內核www.kernel.org
二、解壓內核文件
[root@centos7 ~]# tar xf linux-5.0.7.tar.xz
三、準備.config文件
由於內核編譯需要依靠.config這個配置文件,可以在系統自帶的config文件的基礎上進行修改,系統自帶的config文件在/boot目錄下,需要將其複製到內核解壓的目錄下並改名爲.config
[root@centos7 ~]# cp /boot/config-3.10.0-957.el7.x86_64 ~/linux-5.0.7/.config
四、安裝編譯內核所需要的一些工具
[root@centos7 ~]# yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel ncurses-devel flex bison-devel bison perl-Test-Fatal openssl-devel elfutils-libelf-devel -y
五、執行make menuconfig命令
[root@centos7 linux-5.0.7]# make menuconfig
以下開始進入編譯內核選項
六、開始編譯
[root@centos7 linux-5.0.7]# make -j 12
七、執行make modules_install
執行make modules_install 在/lib/modules目錄下生成新的內核模塊
[root@centos7 linux-5.0.7]# make modules_install
八、生成內核
[root@centos7 linux-5.0.7]# make install
Makefile:159: warning: overriding recipe for target `Makefile'
Makefile:125: warning: ignoring old recipe for target `Makefile'
sh ./arch/x86/boot/install.sh 5.0.7-Masuri arch/x86/boot/bzImage \
System.map "/boot"
九、重啓選擇5.07內核
重啓選擇新的內核
[masuri@centos7 ~]$ uname -r
5.0.7-Masuri
內核的卸載
一、刪除/lib/modules下相應的內核文件
[root@centos7 ~]# rm -rf /lib/modules/5.0.7-Masuri/
二、刪除boot下的相關內核文件
[root@centos7 ~]# rm -rf /boot/*-5.0.7-*
三、清理grub2
此時/boot/grub2/grub.cfg中還有殘留的版本信息,需要將其清理乾淨
menuentry 'CentOS Linux (5.0.7-Masuri) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-45490aa4-cf29-420d-a606-af32688b6707' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 15dcd896-b7cf-48d0-b8bd-4c0b0f2c62b2
else
search --no-floppy --fs-uuid --set=root 15dcd896-b7cf-48d0-b8bd-4c0b0f2c62b2
fi
linux16 /vmlinuz-5.0.7-Masuri root=UUID=45490aa4-cf29-420d-a606-af32688b6707 ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8
initrd16 /initramfs-5.0.7-Masuri.img
}
清理方法使用grub2-mkconfig重新生成新的grub.cfg文件
[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
其他
若要使用ntfs文件系統,可以不必重新編譯內核,只需要安裝ntfs-3g包就行,此包在epel源中。