1.打开grub的默认启动配置文件
sudo gedit /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=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
2.修改默认启动项
GRUB_DEFAULT=4
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_DEFAULT设置默认启动的系统菜单选项,默认是从0开始的;
3.更新生效配置
$ sudo update-grub
[sudo] mango 的密码:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.2.0-36-generic
Found initrd image: /boot/initrd.img-6.2.0-36-generic
Found linux image: /boot/vmlinuz-6.2.0-26-generic
Found initrd image: /boot/initrd.img-6.2.0-26-generic
Found linux image: /boot/vmlinuz-5.17.0-1035-oem
Found initrd image: /boot/initrd.img-5.17.0-1035-oem
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 10 on /dev/sda1
done
4.grub配置的生成
/etc/default/grub 提供了一些简单的配置选项来控制grub的执行流程;
/etc/grub.d 目录中放置了一些脚本,用于生成/boot/grub/grub.cfg文件;
update-grub 此命令会使用以上两个文件生成最终的配置文件/boot/grub/grub.cfg;
$ ls /etc/grub.d
00_header 10_linux_zfs 30_os-prober 40_custom
05_debian_theme 20_linux_xen 30_uefi-firmware 41_custom
10_linux 20_memtest86+ 35_fwupd README