Ubuntu&CentOS更换内核
5
2022-09-05
Ubuntu&CentOS更换内核
Ubuntu
列出不包括当前内核版本的其它所有内核版本:dpkg -l | tail -n +6| grep -E 'linux-image-[0-9]+'| grep -Fv $(uname -r)查看可获取的内核
$ apt-cache search linux | grep 5.4.0-40-generic linux-buildinfo-5.4.0-40-generic - Linux kernel buildinfo for version 5.4.0 on 64 bit x86 SMP linux-cloud-tools-5.4.0-40-generic - Linux kernel version specific cloud tools for version 5.4.0-40 linux-headers-5.4.0-40-generic - Linux kernel headers for version 5.4.0 on 64 bit x86 SMP linux-image-5.4.0-40-generic - Signed kernel image generic linux-image-unsigned-5.4.0-40-generic - Linux kernel image for version 5.4.0 on 64 bit x86 SMP linux-modules-5.4.0-40-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP linux-modules-extra-5.4.0-40-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP linux-tools-5.4.0-40-generic - Linux kernel version specific tools for version 5.4.0-40 linux-modules-nvidia-390-5.4.0-40-generic - Linux kernel nvidia modules for version 5.4.0-40 linux-modules-nvidia-430-5.4.0-40-generic - Transitional package for linux-modules-nvidia-440-ABI-generic linux-modules-nvidia-435-5.4.0-40-generic - Linux kernel nvidia modules for version 5.4.0-40 linux-modules-nvidia-440-5.4.0-40-generic - Linux kernel nvidia modules for version 5.4.0-40下载所需版本的内核
$ sudo apt-get -y update $ sudo apt-get -y install linux-headers-5.4.0-40-generic linux-image-5.4.0-40-generic编辑内核启动顺序
$ vim /etc/default/grub GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-40-generic" #GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=3 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=""更新grub并重启
$ sudo update-grub $ reboot列出软件包
$ dpkg --get-selections |grep linux-image linux-image-5.4.0-40-generic install linux-image-aws installgrub参数介绍
GRUB_DEFAULT=0 // * 默认启动项,按menuentry顺序,从0开始;若改为saved,则默认上次启动项 #GRUB_HIDDEN_TIMEOUT=0 // - 隐藏菜单,grub2不再使用 GRUB_HIDDEN_TIMEOUT_QUIET=true // - true不显示倒计时,屏幕将会是空白的;false空白屏幕上有计时器 GRUB_TIMEOUT=3 // * 设置进入默认启动项的等候时间,默认值10秒;若为-1则一直等待 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" // * 添加内核启动参数,这个为默认 GRUB_CMDLINE_LINUX="acpi_osi=Linux" // * 手动添加内核启动参数,比如 acpi=off noapic等可在这里添加 #GRUB_TERMINAL=console // - 设置是否使用图形介面。去除前面#,仅使用控制台终端,不使用图形介面 # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 // * 设定图形介面分辨率,如不使用默认,把前面#去掉,分辨率按需修改 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true // - 设置grub命令是否使用UUID,去掉#,使用root=/dev/sdax而不用root=UUDI=xxx # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" // - 设定是否创建修复模式菜单项 # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
CentOS
长期支持:lt 最新:ml
$ yum --disablerepo="*" --enablerepo="elrepo-kernel" list available Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn Available Packages elrepo-release.noarch 7.0-6.el7.elrepo elrepo-kernel kernel-lt.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-devel.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-doc.noarch 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-headers.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-tools.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-tools-libs.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-lt-tools-libs-devel.x86_64 5.4.219-1.el7.elrepo elrepo-kernel kernel-ml.x86_64 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-devel.x86_64 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-doc.noarch 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-headers.x86_64 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-tools.x86_64 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-tools-libs.x86_64 6.0.3-1.el7.elrepo elrepo-kernel kernel-ml-tools-libs-devel.x86_64 6.0.3-1.el7.elrepo elrepo-kernel perf.x86_64 5.4.219-1.el7.elrepo elrepo-kernel python-perf.x86_64下载所需内核版本
$ sudo yum --enablerepo="elrepo-kernel" install kernel-lt-5.4.219-1.el7.elrepo.x86_64 -y查看当前启动顺序
$ sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 0 : CentOS Linux (5.4.219-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux 7 Rescue 79b38c152a9ac4695cade22160ce8f9c (3.10.0-1160.76.1.el7.x86_64) 2 : CentOS Linux (3.10.0-1160.76.1.el7.x86_64) 7 (Core) 3 : CentOS Linux (3.10.0-1160.71.1.el7.x86_64) 7 (Core) 4 : CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core) 5 : CentOS Linux (0-rescue-cab9605edaa5484da7c2f02b8fd10762) 7 (Core)设置内核版本并重启
$ grub2-set-default 0 或 $ grub2-set-default 'CentOS Linux (5.4.166-1.el7.elrepo.x86_64) 7 (Core)' $ reboot
- 0
-
分享