Multiboot USB drive

From ArchWiki
Revision as of 13:44, 3 September 2014 by Teateawhy (talk | contribs) (Add new article about creating a multiboot usb stick, largely drawing from the german article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A multiboot USB Flash drive allows booting ISO files by different distributions from a single device. The ISO files can be copied to the drive and booted directly without unpacking them first. In this article GRUB is used as the bootloader. Please note that not all ISO images support this method.

advantages:

  • only a single partition required
  • all ISO files are found in one directory
  • adding and removing ISO files is simple

disadvantages:

  • not all ISO images are compatible
  • the original boot menu for the ISO file is not shown
  • it can be difficult to find a working boot entry

Preparation

At least one partition and a filesystem compatible with GRUB has to be created on the USB drive. See Partitioning and File systems#Create a filesystem.

Installing GRUB

Mount the filesystem located on the USB drive:

mount /dev/sdXY /mnt

Create the directory /boot:

mkdir /mnt/boot

Install grub on the USB drive

grub-install --target=i386-pc --recheck --boot-directory=/mnt/boot /dev/sdX

Configuring GRUB

Create an initial configuration file for GRUB:

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

For every ISO image a boot entry has to be added to grub.cfg. See the next section.

Adding ISO images

It is assumed that the filesystem on the usb drive is mounted to /mnt as previously done. Here the directory /iso will be used for storing the ISO images. If it does not exist yet, create the directory:

mkdir /mnt/iso

Copy the ISO image file to the usb drive:

cp archlinux-2014.08.01-dual.iso /mnt/iso

Add a boot entry for the ISO image to the GRUB configuration file. For example when using the archiso

/mnt/boot/grub/grub.cfg
menuentry "archlinux-2014.08.01-dual.iso" --class iso {
	set isofile="/iso/archlinux-2014.08.01-dual.iso"
	loopback loop (hd1,2)$isofile
	linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201408 img_dev=/dev/sdb2 img_loop=$isofile earlymodules=loop
	initrd (loop)/arch/boot/x86_64/archiso.img
}

For this use case it is easier to add the entry directly to grub.cfg, instead of generating it. Be aware that these entries will be overwritten when calling grub-mkconfig. See Grub#Booting ISO9660 image file directly via GRUB for details. For other ISO images repeat the procedure of copying the file and editing grub.cfg accordingly.

See also