测试环境 生产请慎重!!!
1.先升级gcc
[root@localhost hx]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
[root@localhost hx]#
2.然后
yum install centos-release-scl devtoolset-8-gcc* -y scl
enable devtoolset-8 bash #
永久写进磁盘
echo 'source /opt/rh/devtoolset-8/enable' >> ~/.bashrc
source ~/.bashrc
保存到配置文件电脑再次启动的时候依然有效
3.使用最新的GCC版本
mv /usr/bin/gcc /usr/bin/gcc7.3.1
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-7.3.1
ln -s /opt/rh/devtoolset-8/root/bin/g++
4.make menuconfig
[root@localhost linux-6.5.2]# pwd
/home/hx/linux-6.5.2
编译
等待
make modules_install
继续等待
make install
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg && sudo grub2-set-default 0 && sudo grub2-mkconfig -o /boot/grub2/grub.cfg
然后 grub2-mkconfig -o /boot/grub2/grub.cfg
更新引导配置
内核更新图片
5.
参考
实验:CentOS 7 编译安装最新版内核 Linux Kernel 6.5.2-腾讯云开发者社区-腾讯云
实验:CentOS 7 编译安装最新版内核 Linux Kernel 6.5.2-腾讯云开发者社区-腾讯云
感谢作者 这个新版本的完成了
编译只是个体验 后面才是真正的学习入门
从2.6.0 学起 因为代码有注释 且包比较小
6.5.2 的包很大
参考2
https://zhuanlan.zhihu.com/p/612679832
学习书籍 《Linux Kernel Development, 3rd Edition》 YYJB 永远进步!!
参考3:
CentOS 7 内核 3.10 升级 6.5.2 (RPM 直装 + 源码编译)_内核直装-优快云博客