Ubuntu 设定启动kernel
1. 查看都有那些内核
cat /boot/grub/grub.cfg | grep menuentry
2. 查看 /boot/grub/grub.cfg 中的内容
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0d5ce63b-8900-4a2b-ac84-251bf287bfbf' { submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-0d5ce63b-8900-4a2b-ac84-251bf287bfbf' { menuentry 'Ubuntu, with Linux 5.11.0-41-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-41-generic-advanced-0d5ce63b-8900-4a2b-ac84-251bf287bfbf' { menuentry 'Ubuntu, with Linux 5.11.0-41-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-41-generic-recovery-0d5ce63b-8900-4a2b-ac84-251bf287bfbf' { menuentry 'Ubuntu, with Linux 5.11.0-40-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-40-generic-advanced-0d5ce63b-8900-4a2b-ac84-251bf287bfbf' { menuentry 'Ubuntu, with Linux 5.11.0-40-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnul
menuentry(主菜单):是系统每次启动默认的kernel,对应 /etc/default/grub 中 GRUB_DEFAULT=0
submenu(子菜单):包含系统中所有的启动kernel。
3. 我们想以submenu中 Linux 5.11.0-40-generic 启动,只需要把 /etc/default/grub 中 GRUB_DEFAULT="1 >2",注意1和>之间有空格。
vim /etc/default/grub
文件内容:
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT="1 >2" GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=0 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
4. 更新grub.cfg
update-grub
5. 重启生效
Ubuntu 添加kernel启动参数
1. 在下面的文件中 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 中添加参数
sudo vim /etc/default/grub
2. 使参数生效
sudo update-grub
3. 重启
4. 查看启动项是否正确
cat /proc/cmdline