ubuntu12.04和win7双系统修改启动顺序,学习grub.cfg文件
编辑grub.cfg文件即可:sudogedit /boot/grub/grub.cfg
修改默认的启动系统
setdefault=0 #表示默认从第0个系统启动
win7应该修改为第5个启动(顺序数是第六个)
setdefault=5
2.grub.cfg可以学习到ubuntu开机启动的顺序
sudoupdate-grub进行更新grub.cfg脚本
#
# DONOT EDIT THIS FILE
#
# Itis 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
sethave_grubenv=true
load_env
fi
setdefault="5"
if ["${prev_saved_entry}" ]; then
setsaved_entry="${prev_saved_entry}"
save_envsaved_entry
setprev_saved_entry=
save_envprev_saved_entry
setboot_once=true
fi
functionsavedefault {
if [-z "${boot_once}" ]; then
saved_entry="${chosen}"
save_envsaved_entry
fi
}
functionrecordfail {
setrecordfail=1
if [-n "${have_grubenv}" ]; then if [ -z "${boot_once}"]; then save_env recordfail; fi; fi
}
functionload_video {
insmodvbe
insmodvga
insmodvideo_bochs
insmodvideo_cirrus
}
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
ifloadfont /usr/share/grub/unicode.pf2 ; then
setgfxmode=auto
load_video
insmodgfxterm
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
setlocale_dir=($root)/boot/grub/locale
setlang=zh_CN
insmodgettext
fi
terminal_outputgfxterm
if ["${recordfail}" = 1 ] ; then
settimeout=-1
else
settimeout=10
fi
###END /etc/grub.d/00_header ###
###BEGIN /etc/grub.d/05_debian_theme ###
setmenu_color_normal=white/black
setmenu_color_highlight=black/light-gray
ifbackground_color 44,0,30; then
clear
fi
###END /etc/grub.d/05_debian_theme ###
###BEGIN /etc/grub.d/10_linux ###
functiongfxmode {
setgfxpayload="${1}"
if ["${1}" = "keep" ]; then
setvt_handoff=vt.handoff=7
else
setvt_handoff=
fi
}
if ["${recordfail}" != 1 ]; then
if [-e ${prefix}/gfxblacklist.txt ]; then
ifhwmatch ${prefix}/gfxblacklist.txt 3; then
if[ ${match} = 0 ]; then
setlinux_gfx_mode=keep
else
setlinux_gfx_mode=text
fi
else
setlinux_gfx_mode=text
fi
else
setlinux_gfx_mode=keep
fi
else
setlinux_gfx_mode=text
fi
exportlinux_gfx_mode
if ["${linux_gfx_mode}" != "text" ]; then load_video;fi
#ubuntu启动菜单项,用户界面看到的
menuentry'Ubuntu,Linux3.2.0-86-generic-pae' --class ubuntu --class gnu-linux--class gnu --class os {
recordfail
gfxmode$linux_gfx_mode
insmodgzio
insmodpart_msdos
insmodext2
#对root分区赋予初始值
setroot='(hd0,msdos5)'
#search真正的root分区
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
#引导内核,给root赋值
linux /boot/vmlinuz-3.2.0-86-generic-paeroot=UUID=b7139482-9575-4e5e-bac9-47d4131a13d4 ro quiet splash$vt_handoff
#启动系统initd脚本,实际之后会启动用户bash脚本
initrd /boot/initrd.img-3.2.0-86-generic-pae
}
menuentry'Ubuntu, with Linux 3.2.0-86-generic-pae(recovery mode)' --class ubuntu --class gnu-linux --classgnu --class os {
recordfail
insmodgzio
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
echo '载入Linux3.2.0-86-generic-pae ...'
linux /boot/vmlinuz-3.2.0-86-generic-paeroot=UUID=b7139482-9575-4e5e-bac9-47d4131a13d4 ro recovery nomodeset
echo '载入初始化内存盘...'
initrd /boot/initrd.img-3.2.0-86-generic-pae
}
submenu"Previous Linux versions" {
menuentry'Ubuntu,Linux3.2.0-29-generic-pae' --class ubuntu --class gnu-linux--class gnu --class os {
recordfail
gfxmode$linux_gfx_mode
insmodgzio
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
linux /boot/vmlinuz-3.2.0-29-generic-paeroot=UUID=b7139482-9575-4e5e-bac9-47d4131a13d4 ro quiet splash$vt_handoff
initrd /boot/initrd.img-3.2.0-29-generic-pae
}
menuentry'Ubuntu, with Linux 3.2.0-29-generic-pae(recovery mode)' --class ubuntu --class gnu-linux --classgnu --class os {
recordfail
insmodgzio
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
echo '载入Linux3.2.0-29-generic-pae ...'
linux /boot/vmlinuz-3.2.0-29-generic-paeroot=UUID=b7139482-9575-4e5e-bac9-47d4131a13d4 ro recovery nomodeset
echo '载入初始化内存盘...'
initrd /boot/initrd.img-3.2.0-29-generic-pae
}
}
###END /etc/grub.d/10_linux ###
###BEGIN /etc/grub.d/20_linux_xen ###
###END /etc/grub.d/20_linux_xen ###
###BEGIN /etc/grub.d/20_memtest86+ ###
menuentry"Memory test (memtest86+)"{
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
linux16 /boot/memtest86+.bin
}
menuentry"Memory test (memtest86+, serialconsole 115200)" {
insmodpart_msdos
insmodext2
setroot='(hd0,msdos5)'
search--no-floppy --fs-uuid --set=rootb7139482-9575-4e5e-bac9-47d4131a13d4
linux16 /boot/memtest86+.binconsole=ttyS0,115200n8
}
###END /etc/grub.d/20_memtest86+ ###
###BEGIN /etc/grub.d/30_os-prober ###
#windows菜单项,要包括menuentry双引号"" 和大括号{}才完整,否则不显示菜单
menuentry"Windows 7 (loader) (on /dev/sda1)"--class windows --class os {
insmodpart_msdos
#windows格式为ntfs,或为fat32改为insmodfat
insmodntfs
setroot='(hd0,msdos1)'
search--no-floppy --fs-uuid --set=root 0A123FE6123FD583
chainloader+1
}
settimeout_style=menu
if ["${timeout}" = 0 ]; then
settimeout=10
fi
###END /etc/grub.d/30_os-prober ###
###BEGIN /etc/grub.d/30_uefi-firmware ###
###END /etc/grub.d/30_uefi-firmware ###
###BEGIN /etc/grub.d/40_custom ###
# Thisfile provides an easy way to add custom menu entries. Simply typethe
# menuentries you want to add after this comment. Be careful not tochange
# the'exec tail' line above.
###END /etc/grub.d/40_custom ###
###BEGIN /etc/grub.d/41_custom ###
if [-f $prefix/custom.cfg ]; then
source$prefix/custom.cfg;
fi
###END /etc/grub.d/41_custom ###
更多细节参考官方文档:
http://www.gnu.org/software/grub/manual/grub.html