内容简介
在安装操作系统时,重中之重是制作USB启动盘。大致过程如下,首先下载ISO镜像,然后使用工具将其写入U盘中,最后插入主机并启动,在BIOS中选择USB启动盘。下一次,如果需要安装其他操作系统,你还要重复上述操作。
那有没有更高级的USB启动盘,它包含多种操作系统,在启动之后,可以让我们选择想要安装的任意一种操作系统?
本文将介绍:如何使用单个U盘来制作包含多种操作系统安装镜像的USB启动盘,在系统安装时,通过菜单选择需要安装的操作系统。
解决办法
使用在Linux中的GRUB2直接启动ISO文件。
环境概述
1)、运行Linux发行版的主机。我们将在Debian中制作「多引导USB启动盘」(是的,我们将这种USB启动盘,称之为「多引导USB启动盘」)
2)、另外,你需要准备一块非常大的U盘(毕竟它要容纳多种操作系统安装镜像)。在我们的环境中为/dev/sde设备。
(我们也在考虑加入其他,比如FressBSD、ESXi等等,各种可引导的ISO文件)
第一步、格式化USB存储
该步骤主要做三件事,创建一个主分区,设置为可引导,类型设置为FAT32文件系统:
# fdisk /dev/sde Type d (to delete the existing partition) Type n (to create a new partition) Type p (for primary partition) Type 1 (to create the first partition) Press Enter (to use the first cylinder) Press Enter again (to use the default value as the last cylinder) Type a (for active) Type 1 (to mark the first partition active "bootable") Type t (for partition type) Type c (to use fat32 partition) Type w (to write the changes and close fdisk)
第二步、创建FAT32文件系统
#!/bin/sh mkfs.vfat -F 32 -n MULTIBOOT /dev/sde1
第三步、安装GRUB2引导程序
该步骤做两件事情:安装GRUB2引导程序;配置GRUB2菜单;
安装GRUB2引导程序
#!/bin/sh mkdir /mnt/USB && mount /dev/sde1 /mnt/USB grub-install --force --no-floppy --boot-directory=/mnt/USB/boot /dev/sde # 对于新版本的GRUB,需要使用:--boot-directory=/mnt/USB/boot # 对于旧版本的GRUB,需要使用:--root-directory=/mnt/USB # 否则会产生「Installation is impossible. Aborting」错误
配置GRUB2菜单
#!/bin/sh cd /mnt/USB/boot/grub wget http://pendrivelinux.com/downloads/multibootlinux/grub.cfg
!!!如果无法下载,则使用「grub.cfg」配置文件。
第四步、添加操作系统镜像
在上一步中,已经完成GRUB安装,并配置菜单。该步骤则是添加操作系统安装镜像:
#!/bin/sh cd /mnt/USB # 这里我们只下载了ubuntu的镜像 wget "http://releases.ubuntu.com/13.04/ubuntu-13.04-desktop-i386.iso" -O ubuntu.iso
!!!使用其他镜像:下载到ISO镜像之后,找到其中的syslinux.cfg文件,然后将该文件中的append行追加到grub.cfg的menuentry的linux行中,其他配置是类似的。
第五步、测试启动盘
重启电脑,然后从该USB盘启动,以检查是否可用。
参考文献
Boot Multiple ISO from USB via Grub2 using Linux
Boot Windows 7 iso from grub2
Boot Windows 10 Installer from USB With GRUB