windows和linux雙系統修改啓動項順序

在windows下安裝ubuntu雙系統,啓動時默認選擇ubuntu,至少有三種方法可以修改啓動順序。

1. 修改/boot/grub/grub.cfg

sudo vim /boot/grub/grub.cfg (如果對vim不太熟悉,可以試試sudo gedit /etc/default/grub)

有如下內容

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub


### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

...

menuentry 'Ubuntu,Linux 3.0.0-28-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    set gfxpayload=$linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos8)'
    search --no-floppy --fs-uuid --set=root 6eaff320-f96f-4e63-91d3-9b45bb387d1d
    linux    /boot/vmlinuz-3.0.0-28-generic root=UUID=6eaff320-f96f-4e63-91d3-9b45bb387d1d ro   quiet splash vt.handoff=7
    initrd    /boot/initrd.img-3.0.0-28-generic
}

...

我們修改的是set default="0"。在開機畫面中有啓動項列表,如

Ubuntu,Linux 3.0.0-28-generic

Ubuntu,Linux 3.0.0-28-generic (恢復模式)

Previous Linux versions

Memory test (memtest86+)

Memory test (memtest86+, serial console 115200)

Windows 7 (loader) (on /dev/sda1)

從0計數,windows是5,所以修改爲set default="5". 保存退出,其它任何東西都不要修改。下次啓動就默認windows。

注:windows一般是第5個,如果你用了很久的ubuntu,會有內核更新,一般會形成上面的啓動列表。


 

2. 仍然修改/boot/grub/grub.cfg。

第一個方法修改的是默認序號,類似的,我們可以把windows移到第0個位置。具體的就是把

menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='(hd0,msdos1)'
    search --no-floppy --fs-uuid --set=root A2DE6972DE693FA1
    chainloader +1
}

剪切到第一個menuentry之前,即

if [ "$linux_gfx_mode" != "text" ]; then load_video; fi

menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='(hd0,msdos1)'
    search --no-floppy --fs-uuid --set=root A2DE6972DE693FA1
    chainloader +1
}
menuentry 'Ubuntu,Linux 3.0.0-28-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    set gfxpayload=$linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos8)'
    search --no-floppy --fs-uuid --set=root 6eaff320-f96f-4e63-91d3-9b45bb387d1d
    linux    /boot/vmlinuz-3.0.0-28-generic root=UUID=6eaff320-f96f-4e63-91d3-9b45bb387d1d ro   quiet splash vt.handoff=7
    initrd    /boot/initrd.img-3.0.0-28-generic
}

保存退出。

注:不要剪切錯了,錯了的話我也不知道會有什麼後果,可能沒事。


 

3. 修改/etc/default/grub, 然後update-grub。

sudo 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=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

將GRUB_DEFAULT=0改成GRUB_DEFAULT=5, 保存退出然後運行sudo update-grub。


注:1) 前兩種方法只是暫時的,如果更新內核就會還原回去,從註釋中我們也看到,不要我們修改grub.cfg文件

2) 第三種方法比較好,修改了默認啓動項,之後即使更新內核,也會默認從5啓動;

3) 這裏的方法是對GRUB2而言,從ubuntu11.04開始,GRUB升級,不在使用原先的/boot/grub/menu.lst,老版本修改可以查詢網絡更多內容。

4)以上都是在ubuntu下修改,前提是你安裝的是純正的雙系統,而不是wubi,如果是後者,需要到windows下修改。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章