首先去www.kernel.org下载新的内核,比如在我本次实际操作的时候 第4大版本的最新的longterm 版本为:4.19.47
安装用于编译的基础套件
yum groupinstall "Development Tools" -y
安装其他需要的组件并且下载新内核源码包
yum install -y elfutils-libelf-devel bc openssl-devel ncurses-devel ntpdate vim net-tools;cd /root/下载;ntpdate -u times.aliyun.com;curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.47.tar.xz
tar -xf linux-4.19.47.tar.xz -C /usr/src/
cd /usr/src/linux-4.19.47/
拷贝老的config文件
cp /boot/config-4.4.180-2.el7.elrepo.x86_64 .config
sh -c 'yes "" | make oldconfig'
j4是说使用4个cpu内核来并行处理,应该符合真实的cpu最大内核数情况
make -j4 bzImage
make -j4 modules
make -j4 modules_install
make install
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
配置grub2新的默认内核项,重新启动
grub2-set-default 0 && init 6
检查新内核情况
uname -r
yum groupinstall "Development Tools" -y
yum install -y elfutils-libelf-devel bc openssl-devel ncurses-devel ntpdate vim net-tools;cd /root/下载;ntpdate -u times.aliyun.com;curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.47.tar.xz
tar -xf linux-4.19.47.tar.xz -C /usr/src/
cd /usr/src/linux-4.19.47/
cp /boot/config-4.4.180-2.el7.elrepo.x86_64 .config
sh -c 'yes "" | make oldconfig'
make -j4 bzImage
make -j4 modules
make -j4 modules_install
make install
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
grub2-set-default 0 && init 6
uname -r
补:
yum --disablerepo="*" --enablerepo="elrepo-kernel" install -y kernel-lt-devel-5.4.141-1.el7.elrepo.x86_64 kernel-lt-doc.noarch-5.4.141-1.el7.elrepo.x86_64 kernel-lt-headers-5.4.141-1.el7.elrepo.x86_64 kernel-lt-tools-5.4.141-1.el7.elrepo.x86_64 kernel-lt-tools-libs-5.4.141-1.el7.elrepo.x86_64 kernel-lt-tools-libs-devel-5.4.141-1.el7.elrepo.x86_64
curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.xz
tar -xf linux-4.20.17.tar.xz -C /usr/src/
cd /usr/src/linux-4.20.17/
cp /boot/config-3.10.0-1160.36.2.el7.x86_64 .config
make -j8 bzImage;make -j8 modules;make -j8 modules_install;make install;awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg;grub2-set-default 0 && init 6