一般的 /boot/grub/grub.cfg 文件内容如下:
1: #
2: # DO NOT EDIT THIS FILE
3: #
4: # It is automatically generated by /usr/sbin/grub-mkconfig using templates
5: # from /etc/grub.d and settings from /etc/default/grub
6: #
7:
8: ### BEGIN /etc/grub.d/00_header ###
9: if [ -s $prefix/grubenv ]; then
10: load_env
11: fi
12: set default="4"
13: if [ ${prev_saved_entry} ]; then
14: set saved_entry=${prev_saved_entry}
15: save_env saved_entry
16: set prev_saved_entry=
17: save_env prev_saved_entry
18: set boot_once=true
19: fi
20:
21: function savedefault {
22: if [ -z ${boot_once} ]; then
23: saved_entry=${chosen}
24: save_env saved_entry
25: fi
26: }
27:
28: function recordfail {
29: set recordfail=1
30: if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
31: }
32: insmod ext2
33: set root='(hd0,9)'
34: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
35: if loadfont /usr/share/grub/unicode.pf2 ; then
36: set gfxmode=640x480
37: insmod gfxterm
38: insmod vbe
39: if terminal_output gfxterm ; then true ; else
40: # For backward compatibility with versions of terminal.mod that don't
41: # understand terminal_output
42: terminal gfxterm
43: fi
44: fi
45: insmod ext2
46: set root='(hd0,9)'
47: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
48: set locale_dir=($root)/boot/grub/locale
49: set lang=zh
50: insmod gettext
51: if [ ${recordfail} = 1 ]; then
52: set timeout=-1
53: else
54: set timeout=2
55: fi
56: ### END /etc/grub.d/00_header ###
57:
58: ### BEGIN /etc/grub.d/05_debian_theme ###
59: set menu_color_normal=white/black
60: set menu_color_highlight=black/light-gray
61: ### END /etc/grub.d/05_debian_theme ###
62:
63: ### BEGIN /etc/grub.d/10_linux ###
64: menuentry 'Ubuntu,Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
65: recordfail
66: insmod ext2
67: set root='(hd0,9)'
68: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
69: linux /boot/vmlinuz-2.6.32-21-generic root=UUID=d00d6a7c-6b2d-4def-a7f4-394312384d07 ro quiet splash
70: initrd /boot/initrd.img-2.6.32-21-generic
71: }
72: menuentry 'Ubuntu,Linux 2.6.32-21-generic (恢复模式)' --class ubuntu --class gnu-linux --class gnu --class os {
73: recordfail
74: insmod ext2
75: set root='(hd0,9)'
76: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
77: echo '载入 Linux ...'
78: linux /boot/vmlinuz-2.6.32-21-generic root=UUID=d00d6a7c-6b2d-4def-a7f4-394312384d07 ro single
79: echo '载入引导虚拟磁盘 ...'
80: initrd /boot/initrd.img-2.6.32-21-generic
81: }
82: ### END /etc/grub.d/10_linux ###
83:
84: ### BEGIN /etc/grub.d/20_memtest86+ ###
85: menuentry "Memory test (memtest86+)" {
86: insmod ext2
87: set root='(hd0,9)'
88: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
89: linux16 /boot/memtest86+.bin
90: }
91: menuentry "Memory test (memtest86+, serial console 115200)" {
92: insmod ext2
93: set root='(hd0,9)'
94: search --no-floppy --fs-uuid --set d00d6a7c-6b2d-4def-a7f4-394312384d07
95: linux16 /boot/memtest86+.bin console=ttyS0,115200n8
96: }
97: ### END /etc/grub.d/20_memtest86+ ###
98:
99: ### BEGIN /etc/grub.d/30_os-prober ###
100: menuentry "Windows 7 (loader) (on /dev/sda1)" {
101: insmod ntfs
102: set root='(hd0,1)'
103: search --no-floppy --fs-uuid --set ba52ef7d52ef3caf
104: chainloader +1
105: }
106: menuentry "Windows Vista (loader) (on /dev/sda4)" {
107: insmod ntfs
108: set root='(hd0,4)'
109: search --no-floppy --fs-uuid --set 943af8ff3af8dee4
110: chainloader +1
111: }
112: ### END /etc/grub.d/30_os-prober ###
113:
114: ### BEGIN /etc/grub.d/40_custom ###
115: # This file provides an easy way to add custom menu entries. Simply type the
116: # menu entries you want to add after this comment. Be careful not to change
117: # the 'exec tail' line above.
118: ### END /etc/grub.d/40_custom ###
修改第12行,使得 set default="X" ,X 的值由默认启动的系统在代码中的序列决定,比方说默认启动 win7 (代码中100行), win7 在所有列出系统的第 5 位,则 X = 4,则 set default=”4” 即可。
---EOF---
插入代码时候没有 shell 脚本选项,我选择的是 MSH,显示效果很好,不是吗?