Ubuntu - Grub2.0修改默认启动项

时间:2021-04-19 13:58:56
1. 我的环境:
Ubuntu 10.04
2. 关键位置和文件:
/boot/grub/grub.cfg 文件;
/etc/grub.d/ 目录;
/etc/default/grub 文件;
3. 查看/boot/grub/grub.cfg 文件:
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
}
menuentry "Memory test (memtest86+, serial console 115200)" {
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
}
### END /etc/grub.d/30_os-prober ###
注意:从0开始计数,Ubuntu10.04启动项为0;Windows XP启动项为4;
4. 修改 /etc/default/grub 文件 :
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=4
注意:GRUB_DEFAULT的默认值为0;
5. 执行命令:
$ sudo update-grub
6. 重新启动。