編譯安裝linux-5.07核心
一、下載下傳核心
至核心官方網站下載下傳核心www.kernel.org
二、解壓核心檔案
[[email protected] ~]# tar xf linux-5.0.7.tar.xz
三、準備.config檔案
由于核心編譯需要依靠.config這個配置檔案,可以在系統自帶的config檔案的基礎上進行修改,系統自帶的config檔案在/boot目錄下,需要将其複制到核心解壓的目錄下并改名為.config
[[email protected] ~]# cp /boot/config-3.10.0-957.el7.x86_64 ~/linux-5.0.7/.config
四、安裝編譯核心所需要的一些工具
[[email protected] ~]# 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指令
[[email protected] linux-5.0.7]# make menuconfig
以下開始進入編譯核心選項

六、開始編譯
[[email protected] linux-5.0.7]# make -j 12
七、執行make modules_install
執行make modules_install 在/lib/modules目錄下生成新的核心子產品
[[email protected] linux-5.0.7]# make modules_install
八、生成核心
[[email protected] 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核心
重新開機選擇新的核心
[[email protected] ~]$ uname -r
5.0.7-Masuri
核心的解除安裝
一、删除/lib/modules下相應的核心檔案
[[email protected] ~]# rm -rf /lib/modules/5.0.7-Masuri/
二、删除boot下的相關核心檔案
[[email protected] ~]# 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檔案
[[email protected] ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
其他
若要使用ntfs檔案系統,可以不必重新編譯核心,隻需要安裝ntfs-3g包就行,此包在epel源中。
轉載于:https://blog.51cto.com/11886307/2377516