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