码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu 指定默认启动内核

时间:2020-07-03 12:47:16      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:his   line   linux   class   警告   tty   mode   引号   only   

版本:Ubuntu 18.04

 

可以通过开机启动Ubuntu时按 ESC 键来进入GRUB选项,

选择 Advanced options for Ubuntu,然后可以看到所有内核启动菜单,Index从0开始。

 

或者输入以下命令:

wayde@wayde-desktop:~$ cat /boot/grub/grub.cfg |grep menuentry
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry Ubuntu --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-simple-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
submenu Advanced options for Ubuntu $menuentry_id_option gnulinux-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0-59-generic --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-59-generic-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0-59-generic (recovery mode) --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-59-generic-recovery-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0-53-generic --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-53-generic-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0-53-generic (recovery mode) --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-53-generic-recovery-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0 --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 5.3.0 (recovery mode) --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-5.3.0-recovery-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 4.19.65-d1 --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-4.19.65-d1-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
    menuentry Ubuntu, with Linux 4.19.65-d1 (recovery mode) --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option gnulinux-4.19.65-d1-recovery-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 {
menuentry System setup $menuentry_id_option uefi-firmware {

 

Index同样从0开始,记住你需要指定内核的Index

修改grub文件,修改后如下:

wayde@wayde-desktop:~$ cat /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>6"
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ignore_loglevel log_buf_len=32M console=tty i915.enable_gvt=1 i915.enable_fbc=0 kvm.ignore_msrs=1 intel_iommu=on,igfx_off drm.debug=0"
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"

# Uncomment to disable graphical terminal (grub-pc only)
#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 dont want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# 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"

 

以上只修改了 GRUB_DEFAULT="1>6" 部分,1代表启动时第一层菜单里的 Advanced options for Ubuntu,6即为指定内核的Index。

注意引号是必须的。

 

另一种方法是直接填入内核的名称:

GRUB_DEFAULT="Ubuntu, with Linux 4.19.65-d1"

 

update grub后会有警告提示使用新的名称格式:

root@wayde-desktop:/home/wayde# update-grub
Sourcing file `/etc/default/grubGenerating grub configuration file ...
Found linux image: /boot/vmlinuz-5.3.0-59-generic
Found initrd image: /boot/initrd.img-5.3.0-59-generic
Found linux image: /boot/vmlinuz-5.3.0-53-generic
Found initrd image: /boot/initrd.img-5.3.0-53-generic
Found linux image: /boot/vmlinuz-5.3.0
Found initrd image: /boot/initrd.img-5.3.0
Found linux image: /boot/vmlinuz-4.19.65-d1
Found initrd image: /boot/initrd.img-4.19.65-d1
Warning: Please dont use old title `Ubuntu, with Linux 4.19.65-d1 for GRUB_DEFAULT, use `Advanced options for Ubuntu>Ubuntu, with Linux 4.19.65-d1 (for versions before 2.00) or `gnulinux-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8>gnulinux-4.19.65-d1-advanced-a0b77529-08f4-4fbc-b3a8-85bb77db44e8 (for 2.00 or later)
Adding boot menu entry for EFI firmware configuration
done

按照其提示的名字再次进行修改即可。

 

修改完毕之后:

sudo update-grub

 

重启即可自动从指定内核启动。

 

Ubuntu 指定默认启动内核

标签:his   line   linux   class   警告   tty   mode   引号   only   

原文地址:https://www.cnblogs.com/zoneofmine/p/13229347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!