本人电脑原本是安装win7 64位,后来装双系统加入linux在F盘独立分割一个G的盘给他用
当安装后发现进入界面只有 linux儿没有win7 选项,默认直接进入linux,无法进入win7!所以需要进入grub.cfg中配置文件。原因应该是引导文件被破坏~
cd boot/grub
ls (可以看到grub.cfg 文件,此时权限为—r-r-r )
sudo chmod 777 grub.cfg 改变文件权限为可编辑状态
ll (即可查看文件权限为全打开)、
vi grub.cfg (进入编辑文件状态)
(快捷键 进入vi编辑界面 ,按大写的 G ,则快速跳转到最后一行)
本文就截取需要插入的配置文本 如下:(大家仔细对照自己的grub.cfg文件,就可以发现少掉了或者和中间的部分方法不同,改为相同即可)
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/10_lupin ###
### END /etc/grub.d/10_lupin ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-BA484E09484DC53B' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 BA484E09484DC53B
else
search --no-floppy --fs-uuid --set=root BA484E09484DC53B
fi
parttool ${root} hidden-
chainloader +1
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
set timeout=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 ###
# 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 ###
修改完成后 输入 wq! 保存并退出~
然后将grub.cfg权限改回
sudo chmod 444 grub.cfg
重启即可
以下为个人转的一篇博客,大家可以参考: