linux选择性编译内核,编译安装linux-5.07内核

编译安装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

以下开始进入编译内核选项

76022d225653f8350185414b3c0c8194.png

fc70f10d2900e94e4f4f30285d3be91c.png

09822d38cc95266dfde1e3374501c61e.png

3ac6ff1b30fa2911be075467d1dbe038.png

fdd37b9d4647a275b5e259085ca1d983.png

9e1e38fb5c5ff8ac9e5e773f388f8230.png

六、开始编译

[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内核

重启选择新的内核

be9f49c8bce4c38790c0132cb500cb43.png

[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源中。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值