Ubuntu Kernel 配置和删除

文章目录

  • Ubuntu Kernel 配置和删除
    • 1 显示内核的顺序
    • 2 修改内核默认启动顺序
    • 3 Update grub
    • 4 Reboot
    • 5 Uninstall Kernel

Ubuntu Kernel 配置和删除

最近可能需要频繁换内核,因此记录一下内核的配置和删除。

  • Ref
    • kernel

1 显示内核的顺序

命令

cat /boot/grub/grub.cfg | awk -F"--" '$0 ~ /menuentry/ {print $1}'

结果(序号从0开始)

menuentry 'Ubuntu, with Linux 5.3.0-63-lowlatency'
menuentry 'Ubuntu, with Linux 5.3.0-63-lowlatency (recovery mode)'
menuentry 'Ubuntu, with Linux 5.3.0-63-generic'
menuentry 'Ubuntu, with Linux 5.3.0-63-generic (recovery mode)'
menuentry 'Ubuntu, with Linux 5.3.0-62-lowlatency'
menuentry 'Ubuntu, with Linux 5.3.0-62-lowlatency (recovery mode)'
menuentry 'Ubuntu, with Linux 5.3.0-62-generic'
menuentry 'Ubuntu, with Linux 5.3.0-62-generic (recovery mode)'
menuentry 'Ubuntu, with Linux 4.15.0-112-lowlatency'
menuentry 'Ubuntu, with Linux 4.15.0-112-lowlatency (recovery mode)'
menuentry 'Windows Boot Manager (on /dev/nvme0n1p2)'
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {

2 修改内核默认启动顺序

命令

sudo vim /etc/default/grub

# Change the value of `GRUB_DEFAULT` from 0 to the number you want
# According to my setting, i will choose the 'Windows Boot Manager' as my 
# default boot entry.

修改内容

GRUB_DEFAULT=4

3 Update grub

sudo update-grub

4 Reboot

uname -r

5 Uninstall Kernel

dpkg --get-selections | grep linux | awk '$2 ~ /^install/ {print $0}'

sudo apt-get remove linux-image-***-***
sudo apt-get remove linux-headers-***-***
sudo apt-get remove linux-modules-***-***

sudo update-grub

dpkg --get-selections | grep linux | awk '$2 ~ /^install/ {print $0}'

你可能感兴趣的:(linux)