GRUB2更改系统启动顺序的方法

 方法一:

grub2是通过/etc/grub.d/目录下的文件顺序来决定启动项顺序的:

$cd /etc/grub.d
$ls -l

-rwxr-xr-x 1 root  root  3296 2009-10-24 08:44 00_header
-rwxr-xr-x 1 root  root  1154 2009-10-24 08:31 05_debian_theme
-rwxr-xr-x 1 root  root  3778 2009-10-24 08:44 10_linux
-rwxr-xr-x 1 root  root   772 2009-10-24 00:11 20_memtest86+
-rwxr-xr-x1 shawn shawn 5467 2010-04-17 23:52 30_os-prober
-rwxr-xr-x 1 root  root   214 2009-10-24 08:44 40_custom
-rw-r–r– 1 root  root   483 2009-10-24 08:44 README

30_os-prober是grub2自动生成的,因为我安装ubuntu linux 之前就有vista在电脑上。目录下有各README文件,打开查看里面的内容:

All executable files in this directory are processed in shell expansion order.

00_*: Reserved for 00_header.
10_*: Native boot entries.
20_*: Third party apps (e.g. memtest86+).

The number namespace in-between is configurable by system installer and/or administrator.  For example, you can add an entry to boot another OS as 01_otheros, 11_otheros, etc, depending on the position you want it to occupy in the menu; and then adjust the default setting via /etc/default/grub.

大意是:

该目录下的可以执行文件的顺序是按照shell扩展来排列的(就是按首字符排列的意思,用来配置grub的顺序)。

00_开头的文件是预留给00_header的
10_开头的用于系统本身
20_开头的用于第三方程序

可以新建和改变文件的顺序来配置gurb2的启动顺序。

知道以上这些就好办了。我们只要把30_os-prober的顺序设置到10_linux之前就可以让windows的选项在linux 之前。

运行以下命令把30_os-prober复制一份并且重命名为09_os-prober:

$sudo cp 30_os-prober 09_os-prober

然后去掉30_os-prober的可执行权限:

$sudo chmod 644 30_os-prober
$ls -l

-rwxr-xr-x 1 root  root  3296 2009-10-24 08:44 00_header
-rwxr-xr-x 1 root  root  1154 2009-10-24 08:31 05_debian_theme
-rwxr-xr-x 1 root  root  5467 2009-10-30 00:21 09_os-prober
-rwxr-xr-x 1 root  root  3778 2009-10-24 08:44 10_linux
-rwxr-xr-x 1 root  root   772 2009-10-24 00:11 20_memtest86+
-rw-r–r– 1 shawn shawn 5467 2010-04-17 23:52 30_os-prober
-rwxr-xr-x 1 root  root   214 2009-10-24 08:44 40_custom
-rw-r–r– 1 root  root   483 2009-10-24 08:44 README

然后打开/etc/default/grub把默认启动改成你要的那个:

$sudo gedit /etc/default/grub

找到GRUB_DEFAULT=,改后面的参数。(注意linux 的顺序是从0开始的哦),我设置为第一项vista,于是把默认改成噢0(GRUB_DEFAULT=0)

最后更新grub:

$sudo update-grub

[sudo] password for shawn:
Generating grub.cfg …
Found Windows Vista (loader) on /dev/sda1
Found Windows Vista (loader) on /dev/sda3
Found linux image: /boot/vmlinuz-2.6.31-21-generic
Found initrd image: /boot/initrd.img-2.6.31-21-generic
Found linux image: /boot/vmlinuz-2.6.31-20-generic
Found initrd image: /boot/initrd.img-2.6.31-20-generic
Found memtest86+ image: /boot/memtest86+.bin
done

 

方法2:

 

对于使用ubuntu9.10+的人来说最大的问题就是怎么修改系统的启动顺序。以前的版本可以通过修改menu.lst来更改启动顺序。现在我们需要做得只是修改 /etc/default/grub 文件即可

在终端输入 sudo gedit /etc/default/grub
打开如下文字:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=4 ----------默认的是0 改为你学要启动系统的位置即可,可以在开机的时候自己数以下
#GRUB_HIDDEN_TIMEOUT=0 ----------这一项是决定要不要隐藏开机系统选择界面的,不用管它
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3 ----------这一项改变开机时选择系统时间的,一般改为3就可以了
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=" vga=792 splash"

# 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=1280x800 ------------改变选择系统界面的分辨率,一般默认即可,也可以改为你机子的分辨率,记得把前面的#去掉

# Uncomment if you don't 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_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


修改完成后,保存,退出,然后在终端输入 sudo update-grub 重置你的配置不然你的修改是不会起作用的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值