安顿技巧,5改动双系统运行顺序

By admin in 美高梅手机版4858 on 2019年3月28日

壹 、以root用户登陆.

一、BIOS方式,grub2安装

(说宾博(Beingmate)(Dumex)些,在用U盘制作CentOS7的启航盘后,不必要删除包什么的,也不须求拷贝镜像文件什么的,刻录完正是足以一直动用的,我测试了两台台式的和一个台式机设置都没不通常,可是在装置的时候,要修改下U盘的职位,如下:)

 

 

翻开磁盘情形

.在用u盘安装进度中,在进入安装界面,按tab键修改或然直接按e键:(直接设置是不能够学有所成的,须求修改)

那是1个默许运转Windows的例子:

二、查找windows的menuentry

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

    vmlinuz initrd=initrd.img
inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改为:

 

可在偏下文书档案中查看:

 

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

 

/etc/grub2-efi.cfg

grub2 mbr安装

当中hd:/dev/sdb4是U盘的地方,恐怕不雷同,笔者的是以此,在网上浏览的其他的爱人有sda1的,不驾驭是或不是u盘不等同照旧怎么差别。

  1. 第2找到Windows的menuentry.

/boot/efi/efi/grub.cfg

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

设置第多少个类别centos7后相见了windows7开机时没有带领的标题

 

 

 

消除方法:使用centos系统作为携带类别

# cat   /boot/grub2/grub.cfg | grep Windows

示例:

二、UEFI方式,grub2安装

措施:笔者的做法是修改/boot/grub2/grub.cfg这几个文件,即向这一个文件添加指导windows的脚本

 

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

grub2 UEFI安装

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
 }

 

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

壹 、给Sandisk Ultra U盘在终极分八个 FAT32
格式的分区,并且改变分区类型为:

依然,添加这些

结果:

menuentry ‘Windows Boot Manager (on /dev/sdb1)’
–class windows –class os $menuentry_id_option

0xEF Partition with an EFI file system
 【或许须要】

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

 

 

 menuentry ‘win7 search'{
 insmod chain
 insmod ntfs
 search -f /ntldr –set root
 chainloader +1
 }

menuentry “Windows 7 (loader) (on /dev/sda1)” –class windows –class os
{

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

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

在网上看看另一种格局化解难点,可是,小编做了测试,是不可能兑现的,可是依旧写下做个参考吧

 

 

C:\WINDOWS\system32>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.

#—————————————————

  1. 设置Windows 作为暗中同意的运转项(那儿只好选拔方面命令输出中双引号  “  ” 
    可能单引号    ‘     ‘   中的内容)

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

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

步骤:

 

示例:

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

1、切换到root用户

 

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

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

su

# grub2-set-default  “Windows 7 (loader) (on /dev/sda1)”

 

set timeout=300

二 、执行命令

 

saved_美高梅手机版4858,entry=Windows Boot
Manager (on /dev/sdb1)

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

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

 

 

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

履行详情如下

  1. 证实暗许运营项

重启电脑,就会发觉已经将windows更改为私下认可运营项.

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
}


 

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
}

[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

 

menuentry ” “{
configfile
}


# grub2-editenv list

menuentry “EFI Windows Boot Manager” {
echo “EFI Windows Boot Manager”
#安顿技巧,5改动双系统运行顺序。search –file ($root)/efi/Microsoft/boot/bootmgfw.efi –set=root
terminal_output console
chainloader (hd0,msdos1)/efi/Microsoft/boot/bootmgfw.efi
}

到此修复落成,开机重启就可以看来windows7的引导了(在自作者的电脑上是至极了)
我在Ubuntu上做#sudo
update-grub2

 

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

倒是能够达成上述windows7的指点

输出:

}

#—————————————————

 

menuentry ” “{
configfile
}

以此文件的完毕代码如下:

saved_entry=Windows 7 (loader) (on /dev/sda1)

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

#
 # 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 “Maxdos Toolbox”{
set root='(hd0,msdos1)’
linux16 /boot/Grub/memdisk
initrd16 /PE/imgs/maxdos9.img
}

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

 

menuentry ‘Reboot’ –class reboot {
echo ‘Rebooting …’
reboot
}

 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

  1. 生成,更新grub.cfg  (可选)

menuentry ‘Shutdown’ –class halt {
echo ‘Shutdown …’
halt
}

 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
 }

下边的命令会利用/etc/grub.d下的自动配置脚本和/etc/default/grub中定义的变量,自动生成GRUB2配置文件(包罗在/boot下的基础),-o
钦命输出文件,/boot/grub2/grub.cfg是默许配置文件。即使是多系统,它会自动的把它们找出来,插手到运营菜单列表中去。

 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
 }

 

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

 

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

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

 

 

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

/etc/default/grub 中能够配备timeout,背景图片等。

 ### BEGIN /etc/grub.d/20_ppc_terminfo ###
 ### END /etc/grub.d/20_ppc_terminfo ###

如:

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

 

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

GRUB_TIMEOUT=5

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

GRUB_DISTRIBUTOR=”Fedora”

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

GRUB_DEFAULT=saved

越来越多Ubuntu相关音讯见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

GRUB_CMDLINE_LINUX=”rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0 LANG=en_US.UTF-8″

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

 

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

GRUB_BACKGROUND=/boot/grub2/background.png

美高梅手机版4858 1

 

GRUB_TERMINAL_OUTPUT=gfxterm

GRUB_THEME=/boot/grub2/mytheme/theme.txt

 

 

备考:  上边包车型地铁授命设置Fedora作为暗中同意运行项:

 

 

 

# cat /boot/grub2/grub.cfg |grep Fedora

 

 

结果:

 

menuentry ‘Fedora Linux, with Linux 3.1.2-1.fc16.i686.PAE’ –class
fedora  –class os {

 

menuentry ‘Fedora Linux, with Linux 3.1.1-1.fc16.i686.PAE’ –class
fedora  –class os {

menuentry ‘Fedora Linux, with Linux 3.1.0-7.fc16.i686.PAE’ –class
fedora  –class os {

 

# grub2-set-default “Fedora Linux, with Linux 3.1.2-1.fc16.i686.PAE”

 

# grub2-editenv list

 

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

 

摘自A Curious Programmer

1.
率先找到Windows的menuentry. # cat /boot/grub2/grub.cfg | grep Windows
结果: menuentry Windows 7 (loader) (on /dev/sda1) –cl…

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有