您的位置:时时app平台注册网站 > 时时app平台注册网站 > 安装Windows7 Ubuntu13.04 CentOS7三系统

安装Windows7 Ubuntu13.04 CentOS7三系统

2019-10-18 20:23

执行vim /boot/grub2/grubenv命令:文件修改为如下

2、导入EFI目录到U盘ESP分区的根目录,导入grub程序文件到U盘ESP分区的boot目录。

图片 1

 

menuentry "EFI Windows Boot Manager" {
echo "EFI Windows Boot Manager"
#search --file ($root)/efi/Microsoft/boot/bootmgfw.efi --set=root
terminal_output console
chainloader (hd0,msdos1)/efi/Microsoft/boot/bootmgfw.efi
}

这个文件的完成代码如下:

一、以root用户登陆.

0xEF Partition with an EFI file system  【可能需要】

其中hd:/dev/sdb4是U盘的位置,可能不一样,我的是这个,在网上浏览的其他的朋友有sda1的,不知道是不是u盘不一样还是怎么不同。

三、打开/boot/grub2/grubenv文件,将saved_entry的值改为windows的menuentry:

menuentry "Maxdos Toolbox"{
set root='(hd0,msdos1)'
linux16 /boot/Grub/memdisk
initrd16 /PE/imgs/maxdos9.img
}

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

menuentry 'Windows Boot Manager (on /dev/sdb1)' --class windows --class os $menuentry_id_option

一、BIOS方式,grub2安装

 export menuentry_id_option

/boot/efi/efi/grub.cfg

 

 terminal_output console
 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
 ### END /etc/grub.d/00_header ###

 

menuentry 'Shutdown' --class halt {
echo 'Shutdown ...'
halt
}

    vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOSx207x20x86_64 rd.live.check quiet 改为:

### BEGIN /etc/grub.d/30_os-prober ###

1、给Sandisk Ultra U盘在末段分一个 FAT32 格式的分区,并且改变分区类型为:

 ### BEGIN /etc/grub.d/00_header ###
 set pager=1

...

 

 menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-xxx'{
    insmod chain
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos1'
    chainloader 1
 }

 

}

步骤:

则windows的menuentry是”Windows Boot Manager (on /dev/sdb1)”

menuentry "BIOS Install CentOS71511"{
echo "BIOS Install CentOS71511 Minimal"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ quiet
initrd /isolinux/initrd.img
}

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

二、查找windows的menuentry

set timeout=300

.在用u盘安装过程中,在进入安装界面,按tab键修改或者直接按e键:(直接安装是不能成功的,需要修改)

执行vim /etc/grub2-efi.cfg命令,查找到如下文字:

E:grub-2.02-for-windows>wmic diskdrive list brief
Caption                   DeviceID            Model                     Partitions  Size
INTEL SSDSCKKF256H6L      \.PHYSICALDRIVE0  INTEL SSDSCKKF256H6L      3           256052966400
SanDisk Ultra USB Device  \.PHYSICALDRIVE1  SanDisk Ultra USB Device  2           30746096640

 ### BEGIN /etc/grub.d/10_linux ###
 menuentry 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-8091b91e-1049-4c97-8e64-59fa7cda6671' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod xfs
    set root='hd0,msdos10'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos10 --hint-efi=hd0,msdos10 --hint-baremetal=ahci0,msdos10 --hint='hd0,msdos10'  ab21651b-b9d9-403a-9115-f288ca6b7bd5
    else
      search --no-floppy --fs-uuid --set=root ab21651b-b9d9-403a-9115-f288ca6b7bd5
    fi
    linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=8091b91e-1049-4c97-8e64-59fa7cda6671 ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb quiet LANG=zh_CN.UTF-8
    initrd16 /initramfs-3.10.0-123.el7.x86_64.img
 }

示例:

menuentry 'EFI Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
echo "EFI Install CentOS71511 Minimal"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ quiet
initrd /isolinux/initrd.img

(说明一点,在用U盘制作CentOS7的启动盘后,不需要删除包什么的,也不需要拷贝镜像文件什么的,刻录完就是可以直接使用的,我测试了两台台式的和一个笔记本安装都没有问题,不过在安装的时候,要修改下U盘的位置,如下:)

 

menuentry " "{
configfile
}

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/106597.htm

重启电脑,就会发现已经将windows更改为默认启动项.

grub2 mbr安装

 if [ -s $prefix/grubenv ]; then
  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="${saved_entry}"
 fi

示例:

C:WINDOWSsystem32>f:

D:>cd grub-2.02-for-windows

D:grub-2.02-for-windows>grub-install.exe --target=x86_64-efi --efi-directory=d: --boot-directory=d:boot --bootloader-id=boot --modules="part_msdos fat normal"
Installing for x86_64-efi platform.
Installation finished. No error reported.

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

 

menuentry "DiskGenuis Tool"{
set root='(hd0,msdos1)'
linux16 /boot/Grub/memdisk
initrd16 /PE/imgs/DG_x64.img
}

在网上看到另一种方法解决问题,不过,我做了测试,是不能实现的,不过还是写下做个参考吧

/etc/grub2-efi.cfg

 

[root@localhost jiezh]# grub2-mkconfig -o  /boot/grub2/grub.cfg
 Generating grub configuration file ...
 Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
 Found linux image: /boot/vmlinuz-3.10.0-123.4.2.el7.x86_64
 Found initrd image: /boot/initramfs-3.10.0-123.4.2.el7.x86_64.img
 Found linux image: /boot/vmlinuz-0-rescue-70ff68ea7ac34677a25f45f3417dd76c
 Found initrd image: /boot/initramfs-0-rescue-70ff68ea7ac34677a25f45f3417dd76c.img
 Found Windows 7 (loader) on /dev/sdb1
 done

可在以下文档中查看:

#set prefix=(${root})/boot/Grub/

 

saved_entry=Windows Boot Manager (on /dev/sdb1)

menuentry 'Reboot' --class reboot {
echo 'Rebooting ...'
reboot
}

1、切换到root用户

menuentry "BIOS Windows Boot Manager" {
echo "BIOS Windows Boot Manager"
#set root=(hd0,msdos1)
insmod ntldr
ntldr (hd0,msdos1)/boot/bootmgr
}

或者,添加这个

3、把ESP分区下EFIboot目录下的grubx64.efi文件改名为bootx64.efi

安装第三个系统centos7后遇到了windows7开机时没有引导的问题

menuentry " "{
configfile
}

到此修复完成,开机重启就可以看到windows7的引导了(在我的电脑上是不行了)
我在Ubuntu上做#sudo update-grub2

查看磁盘情况

2、执行命令

E:grub-2.02-for-windows>grub-install.exe --target=i386-pc \.PHYSICALDRIVE1
Installing for i386-pc platform.
Installation finished. No error reported.

 ### 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 ###

二、UEFI方式,grub2安装

grub2-mkconfig -o  /boot/grub2/grub.cfg

把D盘替换成U盘ESP分区实际盘符

倒是可以实现上述windows7的引导

menuentry "BIOS Install CentOS71511 ks"{
echo "BIOS Install CentOS71511 Minimal ks"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ inst.ks=hd:LABEL=ULTRA:/isolinux/ks.cfg quiet
initrd /isolinux/initrd.img
}

 function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
 }

grub2 UEFI安装

su

4、编写grub.cfg配置文件,复制对应的ESP分区下bootgrub目录下

 if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
 else
  menuentry_id_option=""
 fi

 

menuentry 'win7'{
    insmod chain
    insmod ntfs
    set root=(hd0,msdos1)
    chainloader 1
 }

 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
 }

menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-xxx'{
    insmod chain
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos1'
    chainloader 1
 }

解决方法:使用centos系统作为引导系统

 ### BEGIN /etc/grub.d/30_os-prober ###
 menuentry 'Ubuntu 13.04 (13.04) (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-0cbece5c-328e-4f94-aa52-da220cca34a2' {
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos9'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  0cbece5c-328e-4f94-aa52-da220cca34a2
    else
      search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
    fi
    linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
    initrd /boot/initrd.img-3.8.0-19-generic
 }
 submenu 'Advanced options for Ubuntu 13.04 (13.04) (on /dev/sda9)' $menuentry_id_option 'osprober-gnulinux-advanced-0cbece5c-328e-4f94-aa52-da220cca34a2' {
    menuentry 'Ubuntu (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  0cbece5c-328e-4f94-aa52-da220cca34a2
        else
          search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
        fi
        linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
        initrd /boot/initrd.img-3.8.0-19-generic
    }
    menuentry 'Ubuntu,Linux 3.8.0-19-generic (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  0cbece5c-328e-4f94-aa52-da220cca34a2
        else
          search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
        fi
        linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
        initrd /boot/initrd.img-3.8.0-19-generic
    }
    menuentry 'Ubuntu,Linux 3.8.0-19-generic (恢复模式) (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  0cbece5c-328e-4f94-aa52-da220cca34a2
        else
          search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
        fi
        linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro recovery nomodeset locale=zh_CN
        initrd /boot/initrd.img-3.8.0-19-generic
    }
 }

#---------------------------------------------------

 ### 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 ###

    vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quiet


#---------------------------------------------------

 menuentry 'CentOS Linux, with Linux 0-rescue-a9741edb99374138ad3514311cc1ba77' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-a9741edb99374138ad3514311cc1ba77-advanced-8091b91e-1049-4c97-8e64-59fa7cda6671' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod xfs
    set root='hd0,msdos10'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos10 --hint-efi=hd0,msdos10 --hint-baremetal=ahci0,msdos10 --hint='hd0,msdos10'  ab21651b-b9d9-403a-9115-f288ca6b7bd5
    else
      search --no-floppy --fs-uuid --set=root ab21651b-b9d9-403a-9115-f288ca6b7bd5
    fi
    linux16 /vmlinuz-0-rescue-a9741edb99374138ad3514311cc1ba77 root=UUID=8091b91e-1049-4c97-8e64-59fa7cda6671 ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb quiet
    initrd16 /initramfs-0-rescue-a9741edb99374138ad3514311cc1ba77.img
 }
 if [ "x$default" = 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' ]; then default='Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64'; fi;
 ### 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_ppc_terminfo ###
 ### END /etc/grub.d/20_ppc_terminfo ###

 ### END /etc/grub.d/30_os-prober ###


执行详情如下

方法:我的做法是修改/boot/grub2/grub.cfg这个文件,即向这个文件添加引导windows的脚本

 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 'win7 search'{
 insmod chain
 insmod ntfs
 search -f /ntldr --set root
 chainloader 1
 }

本文由时时app平台注册网站发布于时时app平台注册网站,转载请注明出处:安装Windows7 Ubuntu13.04 CentOS7三系统

关键词: