GRUB2_U启

说明

制作环境

本次制作U启实现引导本地系统,引导pe镜像,引导安装光盘。本次制作使用grub2。

U盘:64G,实际57.8G
PE镜像:优启通、Ubuntu、CentOS
系统光盘:Ubuntu-19.10-amd64、CentOS-7-x86-64、Windows10_1909_x64

以上所有没有特定关联要求。

U盘分区

在这里插入图片描述
在grub2引导的一些说明:

  1. bios引导时,U盘为MBR分区可使用ntldr引导,U盘为GPT分区可使用memdisk虚拟光盘引导。
  2. uefi引导时,如果我们需要引导多个镜像,就需要制作多个efi分区,mbr格式的分区数量不足以支持,此点上使用gpt分区。
  3. grub2的loop功能只能在uefi引导下启动,memdisk只能在bios引导下启动。loop功能不能启动iso,memdisk能启动iso。
  4. UEFI只支持fat格式文件系统,所以当loop光盘,链式引导Windows光盘中的bootx64.efi,bootx64.efi是无法引导挂载光盘中的bcd文件。
  5. 在制作GPT格式的U启,需要支持Legacy启动,就要bios分区,当制作完成后该分区可以删除。
  6. 实模式和保护模式,太底层了解不多,简单来说实模式指内存物理地址管理对用户进程非透明,用户可以修改其他任何进程的内存,不安全;保护模式指内存物理地址管理对用户进程透明,内存由系统内核进行管理。基于此,实模式就包含DOS,PE;但对于linux,grub2启动后一直处于实模式,当引导linux内核启动后此时就从实模式转换到保护模式,所以在给linux内核要引导就需要给定根目录和内核要执行安装的iso。上述为自己的理解,有错请指出。

本次制作U启以GPT分区为例。并且后文按照分区一步一步制作。
在这里插入图片描述

#不清楚parted的硬盘显示size为撒偏大?
[root@localhost ~]# lsblk /dev/sdb
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   1 57.8G  0 disk 
├─sdb1   8:17   1  100M  0 part 
├─sdb2   8:18   1    1G  0 part 
├─sdb3   8:19   1   20G  0 part 
├─sdb4   8:20   1   20G  0 part 
└─sdb5   8:21   1 16.7G  0 part 

[root@localhost ~]# parted /dev/sdb print
Model: Kingston DataTraveler 3.0 (scsi)
Disk /dev/sdb: 62.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  106MB   105MB   fat16              boot, esp
 2      106MB   1180MB  1074MB  ntfs               hidden, msftdata
 3      1180MB  22.7GB  21.5GB  ext4               hidden
 4      22.7GB  44.1GB  21.5GB  ntfs               hidden, msftdata
 5      44.1GB  62.0GB  17.9GB  ntfs               msftdata

UEFI分区

磁盘分区

  1. 创建一个新的GPT分区表
[root@localhost ~]# fdisk /dev/sdb 

Command (m for help): g
Created a new GPT disklabel (GUID: E26FDC8B-0190-654B-AF00-B4B5D8A563D0).
  1. 创建uefi分区
Command (m for help): n 
Partition number (1-128, default 1): 
First sector (2048-121110494, default 2048): #2048指扇区数,一个扇区512k,也就是2048*512/1024/1024=1M
Last sector, +sectors or +size{K,M,G,T,P} (2048-121110494, default 121110494): +100M

Created a new partition 1 of type 'Linux filesystem' and of size 100 MiB.
  1. 创建bios分区
Command (m for help): n  #新建bios分区
Partition number (2-128, default 2): 
First sector (206848-121110494, default 206848): 206848
Last sector, +sectors or +size{K,M,G,T,P} (206848-121110494, default 121110494): +1M

Created a new partition 3 of type 'Linux filesystem' and of size 1 MiB.
  1. 修改分区类型
Command (m for help): t  #更改uefi分区类型为EFI System
Partition number (1,2, default 2): 1
Partition type (type L to list all types): 1

Changed type of partition 'Linux filesystem' to 'EFI System'.

Command (m for help): t  #更改bios分区类型为BIOS boot
Partition number (1,2, default 2): 2
Partition type (type L to list all types): 4

Changed type of partition 'Linux filesystem' to 'BIOS boot'.
  1. 显示分区结果
Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: gpt
Disk identifier: 9D28857F-1269-A840-90F7-3F0E391B53AF

Device         Start       End Sectors  Size Type
/dev/sdb1       2048    206847  204800  100M EFI System
/dev/sdb2     206848    208896    2048    1M BIOS boot
  1. 保存分区操作
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 格式化efi分区
[root@localhost ~]# mkfs.vfat /dev/sdb1
mkfs.fat 4.1 (2017-01-24)

grub2安装

grub2需要用到packages,grub2-tools提供程序,执行制作、安装、配置等操作,grub2-pc-modules提供mbr启动所需模块,grub2-efi-i386-modules提供efi-x32位启动所需模块,grub2-efi-x64-modules提供efi-x64位启动所需模块。在grub-install中target参数指定。

  • grub2-tools
[root@localhost ~]# rpm -ql grub2-tools | grep -P "(bin)|(sbin)"
/usr/bin/grub2-mkimage  #grub2的BOOTX64.EFI制作
/usr/bin/grub2-script-check  #grub.cfg配置文件语法检测
/usr/sbin/grub2-install  #grub2引导安装
/usr/sbin/grub2-mkconfig  #自动生成grub.cfg配置文件
/usr/sbin/grub2-probe  #扫描计算机并收集磁盘和分区信息
……
  • grub2-pc-modules
[root@localhost ~]# rpm -ql grub2-pc-modules 
/usr/lib/grub/i386-pc
/usr/lib/grub/i386-pc/acpi.mod
/usr/lib/grub/i386-pc/adler32.mod
/usr/lib/grub/i386-pc/affs.mod
……
  • grub2-efi-x64-modules
[root@localhost ~]# rpm -ql grub2-efi-x64-modules
/usr/lib/grub/x86_64-efi
/usr/lib/grub/x86_64-efi/acpi.mod
/usr/lib/grub/x86_64-efi/adler32.mod
/usr/lib/grub/x86_64-efi/affs.mod
……

有了以上包组,我们可以执行安装操作了:

  1. 创建efi挂载目录并挂载
[root@localhost ~]# mkdir /tmp/sdb1
[root@localhost ~]# mount /dev/sdb1 /tmp/sdb1
  1. grub2安装bios+uefi
[root@localhost ~]# grub2-install --target=i386-pc --boot-directory=/tmp/sdb1/boot/ /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.
[root@localhost ~]# grub2-install --target=x86_64-efi --efi-directory=/tmp/sdb1/ --boot-directory=/tmp/sdb1/boot/ --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.
  1. 删除bios分区
[root@localhost ~]# fdisk /dev/sdb  

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d  #可以删除bios分区
Partition number (1-2, default 2): 2

Partition 3 has been deleted.

Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: gpt
Disk identifier: 9D28857F-1269-A840-90F7-3F0E391B53AF

Device         Start       End Sectors  Size Type
/dev/sdb1       2048    206847  204800  100M EFI System

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 添加配置文件/boot/grub2/grub.cfg
menuentry 'Linux' {
    if search --no-floppy --file --set=root /grub2/grub.cfg ; then
        configfile /grub2/grub.cfg
    fi
}
menuentry 'Windows' {
    if [ 'pc' == $grub_platform ] ; then
        if search --file --set /bootmgr ; then
                chainloader +1
        elif search --file --set /ntldr ; then
                chainloader +1
        fi
    elif [ 'efi' == $grub_platform ] ; then
        if search --file --set=root /EFI/Microsoft/Boot/bootmgfw.efi ; then
                chainloader /EFI/Microsoft/Boot/bootmgfw.efi
        fi
    fi
}
  1. 显示安装后目录结构
[root@localhost ~]# tree /tmp/sdb1/
/tmp/sdb1/
├── boot
│   └── grub2
│       ├── fonts
│       │   └── unicode.pf2
│       ├── grub2.cfg
│       ├── grubenv  #环境快,保存用户操作过程中的一些状态信息
│       ├── i386-pc  #由grub2-pc-modules包提供
│       │  └── *.mod
│       └── x86_64-efi  #由grub2-efi-x64-modules包提供
│           └── *.mod
└── EFI
   └── BOOT
       └── BOOTX64.EFI  #uefi引导文件,可由grub2-mkimage生成

Win PE分区

启动流程

在这里插入图片描述

基本配置

  1. 创建新分区存放pe镜像
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n  #新建分区
Partition number (2-128, default 2): 
First sector (206848-121110494, default 206848): 
Last sector, +sectors or +size{K,M,G,T,P} (206848-121110494, default 121110494): +1G

Created a new partition 2 of type 'Linux filesystem' and of size 1 GiB.

Command (m for help): t  #更改分区类型
Partition number (1,2, default 2): 2
Partition type (type L to list all types): 11

Changed type of partition 'Linux filesystem' to 'Microsoft basic data'.

Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: gpt
Disk identifier: 16AEEA32-1965-E74A-8270-FD3FCB09E6D5

Device      Start     End Sectors  Size Type
/dev/sdb1    2048  206847  204800  100M EFI System
/dev/sdb2  206848 2303999 2097152    1G Microsoft basic data

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 格式分区为ntfs并挂载
[root@localhost ~]# yum -y install ntfsprogs.x86_64 
[root@localhost ~]# mkfs.ntfs /dev/sdb2
[root@localhost ~]# mkdir /tmp/sdb2
[root@localhost ~]# mount -t ntfs /dev/sdb2 /tmp/sdb2/

bios引导方式

  1. 复制memdisk到/boot/grub2/i386-pc/下
[root@localhost ~]# yum -y install syslinux-nonlinux
[root@localhost ~]# mount /dev/sdb1 /tmp/sdb1/
[root@localhost ~]# cp `rpm -ql syslinux-nonlinux | grep memdisk` /tmp/sdb1/boot/grub2/i386-pc/
  1. 准备pe镜像“WIN10PE_x64.iso“
    在这里插入图片描述
[root@localhost ~]# ls /tmp/sdb2/
 WIN10PE_x64.iso
  1. 添加配置/boot/grub2/grub.cfg
menuentry 'WinPE x64' {
    if [ 'pc' == $grup_platform ] ; then
        if search --file --set=root /WIN10PE_x64.iso ; then
            linux $prefix/i386-pc/memdisk iso raw
            initrd /WIN10PE_x64.iso
        fi
    fi
}

uefi引导方式

  1. 从pe镜像“WIN10PE_x64.iso“提取下述文件到分区
    在这里插入图片描述
[root@localhost ~]# tree /tmp/sdb2/
/tmp/sdb2/
├── BOOT
│   └── BOOT.SDI
├── EFI
│   ├── BOOT
│   │   └── bootx64.efi
│   └── MICROSOFT
│       └── BOOT
│           └── BCD
└── SOURCES
│  └── WIN10PE_x64.WIM
└── WIN10PE_x64.iso

BCD文件(有所调整):
在这里插入图片描述

  1. 添加配置/boot/grub2/grub.cfg
menuentry 'WinPE x64' {
    if [ 'efi' == $grub_platform ] ; then
        if search --file --set=root /SOURCES/WIN10PE_x64.WIM ; then
            chainloader /EFI/BOOT/bootx64.efi
        fi
    fi
}

Linux iso引导

  1. 创建新分区存放linux光盘
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition number (3-128, default 3): 
First sector (2304000-121110494, default 2304000): 
Last sector, +sectors or +size{K,M,G,T,P} (2304000-121110494, default 121110494): +20G

Created a new partition 3 of type 'Linux filesystem' and of size 20 GiB.

Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: gpt
Disk identifier: 16AEEA32-1965-E74A-8270-FD3FCB09E6D5

Device       Start      End  Sectors  Size Type
/dev/sdb1     2048   206847   204800  100M EFI System
/dev/sdb2   206848  2303999  2097152    1G Microsoft basic data
/dev/sdb3  2304000 44247039 41943040   20G Linux filesystem

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 格式分区为ext4并挂载
[root@localhost ~]# mkfs.ext4 /dev/sdb3 
[root@localhost ~]# mkdir /tmp/sdb3
[root@localhost ~]# mount /dev/sdb3 /tmp/sdb3/
  1. 准备linux光盘
[root@localhost ~]# ls /tmp/sdb3/
CentOS-7-x86_64-LiveGNOME-1908.iso    CentOS-7-x86_64-Minimal-1908.iso    
ubuntu-19.10-desktop-amd64.iso
  1. 添加配置/boot/grub2/grub.cfg

说明:
(1)这里就会用到我们说的实模式和保护模式,这也是我之前一直不能理解为什么已经loopbac iso,linux vmlinux引导内核启动,为什么还要传递iso-scan/filename,inst.stage2这样指明光盘和根这样的内容。
(2)linux发行版本众多,配置不尽相同,我们应参照光盘中grub.cfg来配置。
(3)经多次测试,loopback光盘后去configfile grub.cfg这个文件不能正确引导光盘执行操作,缺少参数。

  • pe部分
menutry 'CentOS-7' {
set centos=CentOS-7-x86_64-LiveGNOME-1908.iso
    if search --file --set=root /$centos ; then
    	#加载linux内核,传递iso-scan/filename内核参数,由内核加载光盘文件启动pe
        loopback loop /$centos linux (loop)/isolinux/vmlinuz0 root=live:LABEL=CentOS-7-x86_64-LiveGNOME-1908 iso-scan/filename=/$centos rd.live.image
        initrd (loop)/isolinux/initrd0.img
    fi  
    }
menutry 'Ubuntu 19.10' {
    set ubuntu=ubuntu-19.10-desktop-amd64.iso
    if search --file --set=root /$ubuntu ; then
        set gfxpayload=keep
        loopback loop /$ubuntu
        #加载linux内核,传递iso-scan/filename内核参数,由内核加载光盘文件启动pe
        linux (loop)/casper/vmlinuz iso-scan/filename=/$ubuntu
        initrd (loop)/casper/initrd
    fi
    }
}
  • iso部分
menuentry 'CentOS 7' {
    set centos=CentOS-7-x86_64-Minimal-1908.iso
    if search --file --set=root /$centos ; then
        loopback loop /$centos
        probe -u (loop) --set=loopuuid
        set id=UUID=$loopuuid
        #加载linux内核,传递iso-scan/filename内核参数,由内核加载光盘文件启动安装程序
        linux (loop)/images/pxeboot/vmlinuz inst.stage2=hd:$id iso-scan/filename=/$centos
        initrd (loop)/images/pxeboot/initrd.img
    fi
}

menuentry 'Ubuntu 19.10' {
    set ubuntu=ubuntu-19.10-desktop-amd64.iso
    if search --file --set=root /$ubuntu ; then
        loopback loop /$ubuntu
        #加载linux内核,传递iso-scan/filename内核参数,由内核加载光盘文件启动安装程序
        linux (loop)/casper/vmlinuz iso-scan/filename=/$ubuntu only-ubiquity
	    initrd (loop)/casper/initrd
    fi
}

Windows iso引导

基本配置

  1. 创建新分区存放windows光盘
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n  #新建分区
Partition number (4-128, default 4): 
First sector (44247040-121110494, default 44247040): 
Last sector, +sectors or +size{K,M,G,T,P} (44247040-121110494, default 121110494): +20G

Created a new partition 2 of type 'Linux filesystem' and of size 20 GiB.

Command (m for help): t  #更改分区类型
Partition number (1-4 default 4): 4
Partition type (type L to list all types): 11

Changed type of partition 'Linux filesystem' to 'Microsoft basic data'.

Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: gpt
Disk identifier: 16AEEA32-1965-E74A-8270-FD3FCB09E6D5

Device        Start       End  Sectors  Size Type
/dev/sdb1      2048    206847   204800  100M EFI System
/dev/sdb2    206848   2303999  2097152    1G Microsoft basic data
/dev/sdb3   2304000  44247039 41943040   20G Linux filesystem
/dev/sdb4  44247040  86190079 41943040   20G Microsoft basic data

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 格式分区为ntfs并挂载
[root@localhost ~]# yum -y install ntfsprogs.x86_64
[root@localhost ~]# mkfs.ntfs /dev/sdb4
[root@localhost ~]# mkdir /tmp/sdb4
[root@localhost ~]# mount -t ntfs /dev/sdb4 /tmp/sdb4/

bios引导方式

  1. 复制memdisk到/boot/grub2/i386-pc/下
[root@localhost ~]# yum -y install syslinux-nonlinux
[root@localhost ~]# mount /dev/sdb1 /tmp/sdb1/
[root@localhost ~]# cp `rpm -ql syslinux-nonlinux | grep memdisk` /tmp/sdb1/boot/grub2/i386-pc/
  1. 准备windows光盘“Win10_1909.iso“
    在这里插入图片描述
[root@localhost ~]# ls /tmp/sdb2/
[root@localhost ~]# ls /tmp/sdb4/iso/
Win10_1909.iso
  1. 添加配置/boot/grub2/grub.cfg
menuentry 'Win10 1909' {
    set win=Win10_1909.iso
    if [ 'pc' == $grub_platform ] ; then
        if search --file --set=root /iso/$win ; then
            linux $prefix/i386-pc/memdisk iso raw
            initrd /iso/$win
        fi
    fi
}

uefi引导方式

  1. 从windows光盘“Win10_1909.iso“提取下述文件到分区
    在这里插入图片描述
[root@localhost ~]# tree -d -L 1 /tmp/sdb4
/tmp/sdb4
├── boot
├── efi
└── sources
  1. 添加配置/boot/grub2/grub.cfg
menuentry 'Win10 1909' {
    if [ 'efi' == $grub_platform ] ; then
        if search --file --set=root /iso/$win ; then
             chainloader /efi/boot/bootx64.efi
        fi
    fi
}

补充

U盘为mbr分区格式下,BIOS引导执行过程:
在这里插入图片描述

  1. 磁盘分区
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
#bios
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x967a6aa2.
The old gpt signature will be removed by a write command.

#efi(100M)分区
#用命令a设置efi分区为bootable flag
#用命令t设置efi分区类型为EFI
#mbr格式时,bios启动可使用ntldr /bootmgr来引导win pe
Command (m for help): p
Disk /dev/sdb: 57.8 GiB, 62008590336 bytes, 121110528 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
Disklabel type: dos
Disk identifier: 0x967a6aa2

Device     Boot  Start     End Sectors  Size Id Type
/dev/sdb1  *      2048  206847  204800  100M ef EFI (FAT-12/16/32)
  1. 提取镜像文件
    从pe镜像“WIN10PE_x64.iso“提取下述文件到分区
    在这里插入图片描述
[root@localhost ~]# tree /tmp/sdb2/
/tmp/sdb2/
├── BOOT
│   ├── BCD
│   └── BOOT.SDI
├── BOOTMGR
└── SOURCES
   └── WIN10PE_x64.WIM

BOOTMGR:
在这里插入图片描述
BCD:
在这里插入图片描述
3. 添加配置

menuentry 'WinPE x64' {
    if [ 'pc' == $grup_platform ] ; then
        if search --file --set=root /WIN10PE_x64.WIM ; then
            ntldr /BOOTMGR
        fi
    fi
}

grub.cfg

set default=0
set timeout=5

insmod lvm
insmod fat
insmod exfat
insmod ntfs
insmod iso9660
insmod ext2
insmod xfs
insmod part_gpt

submenu 'Start   System' {

    menuentry 'Linux' {
    if search --no-floppy --file --set=root /grub2/grub.cfg ; then
        configfile /grub2/grub.cfg
    fi
    }

    menuentry 'Windows' {
    if [ 'pc' == $grub_platform ] ; then
	if search --file --set /bootmgr ; then
		chainloader +1
	elif search --file --set /ntldr ; then
		chainloader +1
	fi
    elif [ 'efi' == $grub_platform ] ; then
	if search --file --set=root /EFI/Microsoft/Boot/bootmgfw.efi ; then
		chainloader /EFI/Microsoft/Boot/bootmgfw.efi
	fi
    fi
    }
}

submenu 'Start   PE' {
    menuentry 'WinPE x64' {
    if search --set=device --no-floppy --file /boot/grub2/grub.cfg ; then
        probe --set=part --partmap $device
        if [ 'mbr' == $part -a 'pc' == $grub_platform ] ; then
            if search --file --set=root /SOURCES/WIN10PE_x64.WIM ; then
                ntldr /BOOTMGR
            fi
        fi
        if [ 'gpt' == $part -a 'pc' == $grub_platform ] ; then
            if search --file --set=root /WIN10PE_x64.iso ; then
                linux $prefix/i386-pc/memdisk iso raw
                initrd /WIN10PE_x64.iso
            fi
        fi
    fi
    if [ 'efi' == $grub_platform ] ; then
        if search --file --set=root /SOURCES/WIN10PE_x64.WIM ; then
            chainloader /EFI/BOOT/bootx64.efi
        fi
    fi
    }
    
    menuentry 'CentOS 7' {
    set centos=CentOS-7-x86_64-LiveGNOME-1908.iso
    if search --file --set=root /$centos ; then
        loopback loop /$centos
        linux (loop)/isolinux/vmlinuz0 root=live:LABEL=CentOS-7-x86_64-LiveGNOME-1908 iso-scan/filename=/$centos rd.live.image
        initrd (loop)/isolinux/initrd0.img
    fi
    }

    menuentry 'Ubuntu 19.10' {
    set ubuntu=ubuntu-19.10-desktop-amd64.iso
    if search --file --set=root /$ubuntu ; then
        set gfxpayload=keep
        loopback loop /$ubuntu
        linux (loop)/casper/vmlinuz iso-scan/filename=/$ubuntu
        initrd (loop)/casper/initrd
    fi
    }
}

submenu 'Install System' {

    menuentry 'CentOS 7' {
    set centos=CentOS-7-x86_64-Minimal-1908.iso
    if search --file --set=root /$centos ; then
        loopback loop /$centos
        probe -u (loop) --set=loopuuid
        set id=UUID=$loopuuid
        linux (loop)/images/pxeboot/vmlinuz inst.stage2=hd:$id iso-scan/filename=/$centos
        initrd (loop)/images/pxeboot/initrd.img
    fi
    }

    menuentry 'Ubuntu 19.10' {
    set ubuntu=ubuntu-19.10-desktop-amd64.iso
    if search --file --set=root /$ubuntu ; then
        loopback loop /$ubuntu
        linux (loop)/casper/vmlinuz iso-scan/filename=/$ubuntu only-ubiquity
	    initrd (loop)/casper/initrd
    fi
    }

    menuentry 'Win10 1909' {
    set win=Win10_1909.iso
    if [ 'pc' == $grub_platform ] ; then
        if search --file --set=root /iso/$win ; then
            linux $prefix/i386-pc/memdisk iso raw
            initrd /iso/$win
        fi
    fi
    if [ 'efi' == $grub_platform ] ; then
        if search --file --set=root /iso/$win ; then
             chainloader /efi/boot/bootx64.efi
        fi
    fi
    }
}

submenu 'Power   Manager' {
    menuentry 'reboot' { reboot }
    menuentry 'halt' { halt }
}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值