我的win7是mbr安装,Debian是UEFI安装,
下面是我的/boot/grub/grub.cfg:
============================= sda7/grub/grub.cfg: ==============================
--------------------------------------------------------------------------------
#
# 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
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
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
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_gpt
insmod ext2
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 82d7d012-58c2-4ccf-ada1-b1fe3a732453
else
search --no-floppy --fs-uuid --set=root 82d7d012-58c2-4ccf-ada1-b1fe3a732453
fi
font="/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=zh_CN
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
set timeout=-1
else
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
insmod part_gpt
insmod ext2
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 82d7d012-58c2-4ccf-ada1-b1fe3a732453
else
search --no-floppy --fs-uuid --set=root 82d7d012-58c2-4ccf-ada1-b1fe3a732453
fi
insmod png
if background_image /usr/share/images/desktop-base/lines-grub.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-82d7d012-58c2-4ccf-ada1-b1fe3a732453' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt7'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt7 --hint-efi=hd0,gpt7 --hint-baremetal=ahci0,gpt7 06f48d35-38c4-4cc8-a202-92fc4be7f408
else
search --no-floppy --fs-uuid --set=root 06f48d35-38c4-4cc8-a202-92fc4be7f408
fi
echo '载入 Linux 3.16.0-4-amd64 ...'
linux /vmlinuz-3.16.0-4-amd64 root=UUID=82d7d012-58c2-4ccf-ada1-b1fe3a732453 ro quiet
echo '载入初始化内存盘...'
initrd /initrd.img-3.16.0-4-amd64
}
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-82d7d012-58c2-4ccf-ada1-b1fe3a732453' {
menuentry 'Debian GNU/Linux,Linux 3.16.0-4-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-amd64-advanced-82d7d012-58c2-4ccf-ada1-b1fe3a732453' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt7'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt7 --hint-efi=hd0,gpt7 --hint-baremetal=ahci0,gpt7 06f48d35-38c4-4cc8-a202-92fc4be7f408
else
search --no-floppy --fs-uuid --set=root 06f48d35-38c4-4cc8-a202-92fc4be7f408
fi
echo '载入 Linux 3.16.0-4-amd64 ...'
linux /vmlinuz-3.16.0-4-amd64 root=UUID=82d7d012-58c2-4ccf-ada1-b1fe3a732453 ro quiet
echo '载入初始化内存盘...'
initrd /initrd.img-3.16.0-4-amd64
}
menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-amd64-recovery-82d7d012-58c2-4ccf-ada1-b1fe3a732453' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt7'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt7 --hint-efi=hd0,gpt7 --hint-baremetal=ahci0,gpt7 06f48d35-38c4-4cc8-a202-92fc4be7f408
else
search --no-floppy --fs-uuid --set=root 06f48d35-38c4-4cc8-a202-92fc4be7f408
fi
echo '载入 Linux 3.16.0-4-amd64 ...'
linux /vmlinuz-3.16.0-4-amd64 root=UUID=82d7d012-58c2-4ccf-ada1-b1fe3a732453 ro single
echo '载入初始化内存盘...'
initrd /initrd.img-3.16.0-4-amd64
}
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {
fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------
我按照网上说的办法在### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###之间添加了win7的启动项之后,然后运行update-grub,显示下面的结果:
root@localhost:/boot/grub# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.16.0-4-amd64
Found initrd image: /boot/initrd.img-3.16.0-4-amd64
Adding boot menu entry for EFI firmware configuration
done
然后我再打开/boot/grub/grub.cfg查看,发现### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###之间的win7的启动项又消失了,之前的改动没有任何效果。
另外这一句:Adding boot menu entry for EFI firmware configuration 让我很奇怪,应该是grub.cfg里的
### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {
fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###
这一段导致的,我发现这一句也是删除后再update-grub后又自动恢复。
我的开机启动界面差不多下面的样子:
1.Debian8
2.Debian8 ***mode
3.Setup
其中前两项都正常,第三项我点开后加载的是BIOS界面,我也感到很奇怪,这一项的出现应该跟上面提到的Adding boot menu entry for EFI firmware configuration有关。。
下面是我的电脑的信息:
求助各位大神

Boot Info Script 0.61 [1 April 2012]
============================= Boot Info Summary: ===============================
=> Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector
764458024 of the same hard drive for core.img, but core.img can not be
found at this location.
=> Grub2 (v1.99) is installed in the MBR of /dev/sdb and looks at sector 1 of
the same hard drive for core.img. core.img is at this location and looks
in partition 135 for .
sda1: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sda2: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sda3: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Debian GNU/Linux 8
Boot files: /etc/fstab
sda4: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files:
sda5: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files:
sda6: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sda7: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files: /grub/grub.cfg
sda8: __________________________________________________________________________
File system: vfat
Boot sector type: FAT32
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sda9: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files:
sdb1: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows 7
Boot files: /grldr /bootmgr /Boot/BCD
/Windows/System32/winload.exe /grldr
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 1 976,773,167 976,773,167 ee GPT
GUID Partition Table detected.
Partition Start Sector End Sector # of Sectors System
/dev/sda1 66 314,834,986 314,834,921 Data partition (Windows/Linux)
/dev/sda2 314,834,987 629,407,786 314,572,800 Data partition (Windows/Linux)
/dev/sda3 629,409,792 736,829,439 107,419,648 Data partition (Linux)
/dev/sda4 736,829,440 742,688,767 5,859,328 Data partition (Linux)
/dev/sda5 742,688,768 756,361,215 13,672,448 Data partition (Linux)
/dev/sda6 756,361,216 764,174,335 7,813,120 Swap partition (Linux)
/dev/sda7 764,174,336 766,128,127 1,953,792 Data partition (Linux)
/dev/sda8 766,128,128 770,033,663 3,905,536 EFI System partition
/dev/sda9 770,033,664 976,771,071 206,737,408 Data partition (Linux)
Drive: sdb _____________________________________________________________________
Disk /dev/sdb: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sdb1 * 63 250,067,789 250,067,727 7 NTFS / exFAT / HPFS
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/sda1 000EF40800028FBE ntfs 文档
/dev/sda2 CCC0D172C0D1636E ntfs 娱乐
/dev/sda3 82d7d012-58c2-4ccf-ada1-b1fe3a732453 ext4
/dev/sda4 a58acc41-e7d9-429f-9bca-9376b27eea37 ext4
/dev/sda5 0b504b34-ef21-4962-a8e2-158991624280 ext4
/dev/sda6 3e0ad058-447a-429b-abd2-2293e5588178 swap
/dev/sda7 06f48d35-38c4-4cc8-a202-92fc4be7f408 ext4
/dev/sda8 C40C-6DCE vfat
/dev/sda9 2f935ce0-12fa-4971-ae33-75e8d9b4f7c8 ext4
/dev/sdb1 6E0E36220E35E3AD ntfs Win7
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/sda3 / ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda4 /tmp ext4 (rw,relatime,data=ordered)
/dev/sda5 /var ext4 (rw,relatime,data=ordered)
/dev/sda7 /boot ext4 (rw,relatime,data=ordered)
/dev/sda8 /boot/efi vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)
/dev/sda9 /home ext4 (rw,relatime,data=ordered)
/dev/sdb1 /media/lee/Win7 fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)
=============================== sda3/etc/fstab: ================================
--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda3 during installation
UUID=82d7d012-58c2-4ccf-ada1-b1fe3a732453 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda7 during installation
UUID=06f48d35-38c4-4cc8-a202-92fc4be7f408 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sda8 during installation
UUID=C40C-6DCE /boot/efi vfat umask=0077 0 1
# /home was on /dev/sda9 during installation
UUID=2f935ce0-12fa-4971-ae33-75e8d9b4f7c8 /home ext4 defaults 0 2
# /tmp was on /dev/sda4 during installation
UUID=a58acc41-e7d9-429f-9bca-9376b27eea37 /tmp ext4 defaults 0 2
# /var was on /dev/sda5 during installation
UUID=0b504b34-ef21-4962-a8e2-158991624280 /var ext4 defaults 0 2
# swap was on /dev/sda6 during installation
UUID=3e0ad058-447a-429b-abd2-2293e5588178 none swap sw 0 0
--------------------------------------------------------------------------------
=================== sda3: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)