Multiboot USB drive - ArchWiki

# Multiboot USB drive

Related articles

- GRUB
- Syslinux
- Archiso

This article or section is a candidate for moving to Multiboot disk images.

Notes: See discussion (Discuss)

A multiboot USB flash drive allows booting multiple ISO files from a single device. The ISO files can be copied to the drive and booted directly without unpacking them first. There are multiple methods available, but they may not work for all ISO images.

## Using GRUB and loopback devices

This article or section needs language, wiki syntax or style improvements.

Reason: multiple style issues (Discuss)

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

This article or section needs expansion.

Reason: How much extra space is needed for the bootloader? (Discuss)

Create at least one partition and a filesystem supported by GRUB on the USB drive. See Partitioning and File systems#Create a filesystem. Choose the size based on the total size of the ISO files that you want to store on the drive, and plan for extra space for the bootloader.

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

In case you want to boot ISOs in UEFI mode, you have to install grub for the UEFI target:

    # grub-install --target x86_64-efi --efi-directory /mnt --boot-directory=/mnt/boot --removable

For UEFI, the the partition has to be the first one in an MBR partition table and formatted with FAT32.

### Configuring GRUB

For the purpose of multiboot USB drive it is easier to edit `grub.cfg` by hand instead of generating it. Alternatively, make the following changes in `/etc/grub.d/40_custom` or `/mnt/boot/grub/custom.cfg` and generate `/mnt/boot/grub/grub.cfg` using grub-mkconfig.

As it is recommend to use a persistent name instead of `/dev/sdxY` to identify the partition on the USB drive where the image files are located, define a variable for convenience to hold the value:

    /mnt/boot/grub/grub.cfg

    # path to the partition holding ISO images (using UUID)
    set imgdevpath="/dev/disk/by-uuid/UUID_value"

Alternatively, use the device label instead of UUID:

    /mnt/boot/grub/grub.cfg

    # path to the partition holding ISO images (using labels)
    set imgdevpath="/dev/disk/by-label/label_value"

The necessary UUID or label can be found using `lsblk -f`. Do not use the same label as the Arch ISO for the USB device, otherwise the boot process will fail.

To complete the configuration, a boot entry for each ISO image has to be added below this header, see the next section for examples.

### Boot entries

This article or section needs language, wiki syntax or style improvements.

Reason: The only boxes used should be code blocks, otherwise the section will be unreadable. Anything else should be plain text. (Discuss)

It is assumed that the ISO images are stored in the `boot/iso/` directory on the same filesystem where GRUB is installed. Otherwise it would be necessary to prefix the path to ISO file with device identification when using the `loopback` command, for example `loopback loop (hd1,2)$isofile`. As this identification of devices is not persistent, it is not used in the examples in this section.

#### Arch Linux

Tip: If you want to boot into a 32-bit system, replace `x86_64` with `i686`.

##### monthly release

    menuentry '[loopback]archlinux-2014.12.01-dual.iso' {
    	set isofile='/boot/iso/archlinux-2014.12.01-dual.iso'
    	loopback loop $isofile
    	linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201412 img_dev=$imgdevpath img_loop=$isofile earlymodules=loop
    	initrd (loop)/arch/boot/x86_64/archiso.img
    }

Note:

- The label string after `archisolabel=` needs to be edited when a newer, monthly released ISO image is used.[1]
- For a complete list of archiso boot parameters, see its documentation.

##### archboot

See also: Archboot

    menuentry '[loopback]archlinux-2014.11-1-archboot' {
    	set isofile='/boot/iso/archlinux-2014.11-1-archboot.iso'
    	loopback loop $isofile
    	linux (loop)/boot/vmlinuz_x86_64 iso_loop_dev=$imgdevpath iso_loop_path=$isofile
    	initrd (loop)/boot/initramfs_x86_64.img
    }

#### CentOS

##### Stock installation medium

Note: Here we use `*-DVD.iso`, you can replace it by `*-Minimal.iso` or `*-NetInstall.iso` which could be download from here. The iso file can't be put on an NTFS partition, otherwise the second stage loader can not work.

    menuentry '[loopback]CentOS-7.0-1406-x86_64-DVD' {
    	set isofile='/boot/iso/CentOS-7.0-1406-x86_64-DVD.iso'
    	loopback loop $isofile
    	linux (loop)/isolinux/vmlinuz noeject inst.stage2=hd:/dev/sdb2:/$isofile
    	initrd (loop)/isolinux/initrd.img
    }

Tip: The boot parameter of second stage install image location `/dev/sdb2` which is used by anaconda, is similar to fstab's first field(fs_spec), could be replace with one of:

- `/dev/sdxY`
- `LABEL=MYUSBSTICK`
- `UUID=00000000-0000-0000-0000-0000deadbeef`

For example, `linux (loop)/isolinux/vmlinuz noeject inst.stage2=hd:LABEL=MYUSBSTICK:/$isofile`

##### Desktop live medium

    menuentry '[loopback]CentOS-7.0-1406-x86_64-GnomeLive' {
    	set isofile='/boot/iso/CentOS-7.0-1406-x86_64-GnomeLive.iso'
    	loopback loop $isofile
    	linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=CentOS-7-live-GNOME-x86_64 iso-scan/filename=$isofile rd.live.image
    	initrd (loop)/isolinux/initrd0.img
    }

#### Clonezilla Live

Tip: Since 2014.01.05[2], the Arch Linux monthly release contains clonezilla/drbl.

    menuentry "Clonezilla Live 2.2.3-25 amd64" --class iso {
        set isofile="/boot/iso/clonezilla-live-2.2.3-25-amd64.iso"
        loopback loop $isofile
        linux (loop)/live/vmlinuz findiso=$isofile boot=live union=aufs config noprompt ip=frommedia toram=filesystem.squashfs
        initrd (loop)/live/initrd.img
    }

#### Debian

##### Stock install medium

Note: To install debian from any stock install medium on a hard disk(or usb stick), it's necessary to use a different initramfs instead of the default one on the installation medium(it is located at `(loop)/install.amd/initrd.gz`). If you boot with the default one, the debian-installer will unable to find or mount the proper iso image for installation. Please download the initramfs for hard disk installation from an official mirror site, put it in the same directory with the image file and give it a suitable name(`debian-7.8.0-amd64-DVD-1.hdd.initrd.gz` in this example).

    menuentry '[loopback]debian-7.8.0-amd64-DVD-1' {
    	set isofile='/boot/iso/debian-7.8.0-amd64-DVD-1.iso'
    	set initrdfile='/boot/iso/debian-7.8.0-amd64-DVD-1.hdd.initrd.gz'
    	loopback loop $isofile
    	linux (loop)/install.amd/vmlinuz vga=791 iso-scan/ask_second_pass=true iso-scan/filename=$isofile
    	initrd $initrdfile
    }

##### Live install medium

    menuentry '[loopback]debian-live-7.8.0-amd64-xfce-desktop' {
    	set isofile='/boot/iso/debian-live-7.8.0-amd64-xfce-desktop.iso'
    	loopback loop $isofile
    	linux (loop)/live/vmlinuz boot=live config fromiso=/dev/sdb2/$isofile
    	initrd (loop)/live/initrd.img
    }

Note: It's also OK to use `findiso=$isofile` instead of the longer `fromiso=/dev/disk/by-.../.../$isofile`. Anyway, using `fromiso=` instead of `findiso=` may speed up the initialization progress because it avoids unnecessary mounting.

#### Fedora

##### Stock installation medium

    menuentry '[loopback]Fedora-20-x86_64-DVD' {
    	set isofile='/boot/iso/Fedora-20-x86_64-DVD.iso'
    	loopback loop $isofile
    	linux (loop)/isolinux/vmlinuz noeject inst.stage2=hd:/dev/sdb2:/$isofile
    	initrd (loop)/isolinux/initrd.img
    }

Tip: For a list of anaconda boot parameters, please see this documentation.

##### Workstation live medium

    menuentry '[loopback]Fedora-Live-Workstation-x86_64-21-5' {
    	set isofile='/boot/iso/Fedora-Live-Desktop-x86_64-21-5.iso'
    	loopback loop $isofile
    	linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=Fedora-Live-WS-x86_64-21-5 iso-scan/filename=$isofile rd.live.image
    	initrd (loop)/isolinux/initrd0.img
    }

#### GParted Live

    menuentry "GParted Live" {
          set isofile="/boot/iso/gparted-live-0.18.0-1-amd64.iso"
          loopback loop $isofile
          linux (loop)/live/vmlinuz boot=live config union=aufs noswap noprompt ip=frommedia toram=filesystem.squashfs findiso=$isofile
          initrd (loop)/live/initrd.img
    }

#### Kali Linux

    menuentry '[loopback]kali-linux-1.0.7-amd64' {
    	set isofile='/boot/iso/kali-linux-1.0.7-amd64.iso'
    	loopback loop $isofile
    	linux (loop)/live/vmlinuz boot=live findiso=$isofile noconfig=sudo username=root hostname=kali
    	initrd (loop)/live/initrd.img
    }

#### Linux Mint

    menuentry "[loopback]linuxmint-201403-cinnamon-dvd-32bit" {
    	set isofile="/boot/iso/linuxmint-201403-cinnamon-dvd-32bit.iso"
    	loopback loop $isofile
    	linux (loop)/live/vmlinuz isofrom=/dev/sdb2/iso/$isofile boot=live live-config live-media-path=/live quiet splash noeject noprompt
    	initrd (loop)/live/initrd.img
    }

#### openSUSE

##### Stock installation medium

    menuentry '[loopback]openSUSE-13.1-DVD-x86_64' {
    	set isofile='/boot/iso/openSUSE-13.1-DVD-x86_64.iso'
    	loopback loop $isofile
    	linux (loop)/boot/x86_64/loader/linux install=hd:$isofile
    	initrd (loop)/boot/x86_64/loader/initrd
    }

##### LiveCD

    menuentry '[loopback]openSUSE-13.1-KDE-Live-x86_64' {
    	set isofile='/boot/iso/openSUSE-13.1-KDE-Live-x86_64.iso'
    	loopback loop $isofile
    	linux (loop)/boot/x86_64/loader/linux isofrom_device=$imgdevpath isofrom_system=$isofile LANG=en_US.UTF-8
    	initrd (loop)/boot/x86_64/loader/initrd
    }

#### Sabayon

    menuentry '[loopback]Sabayon_Linux_14.05_amd64_KDE' {
    	set isofile='/boot/iso/Sabayon_Linux_14.05_amd64_KDE.iso'
    	loopback loop $isofile
    	linux (loop)/boot/sabayon root=/dev/ram0 aufs cdroot locale=en_US loop=/livecd.squashfs looptype=squashfs isoboot=$isofile
    	initrd (loop)/boot/sabayon.igz
    }

#### Slackware Linux

    menuentry '[loopback]slackware64-14.1-install-dvd' {
    	set isofile='/boot/iso/slackware64-14.1-install-dvd.iso'
    	loopback loop $isofile
    	linux (loop)/kernels/huge.s/bzImage printk.time=0
    	initrd (loop)/isolinux/initrd.img
    }

#### SystemRescueCd

Note: Replace `64` with `32` if you want to boot into a 32-bit system.

    menuentry "System Rescue CD 64" {
    	set isofile='/boot/iso/systemrescuecd-x86-x.y.z.iso'
    	loopback loop $isofile
    	linux (loop)/isolinux/rescue64 isoloop=$isofile
    	initrd (loop)/isolinux/initram.igz
    }

#### Ubuntu

    menuentry '[loopback]ubuntu-14.04.1-desktop-amd64' {
    	set isofile='/boot/iso/ubuntu-14.04.1-desktop-amd64.iso'
    	loopback loop $isofile
    	linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile locale=en_US.UTF-8
    	initrd (loop)/casper/initrd.lz
    }

#### Slitaz

First, download slitaz iso, then extract somewhere (in this case, /live/slitaz-4.0 on /dev/sda3)

    menuentry 'slitaz-4.0 core' {
    	set dir='/live/slitaz-4.0'
    	set root=(hd0,msdos3)
    	set lang='pt_BR'
    	set kmap='br-abnt2'
    	linux ($root)/$dir/bzImage lang=$lang kmap=$kmap rw root=/dev/null vga=normal autologin
    	initrd ($root)/$dir/rootfs4.gz ($root)/$dir/rootfs3.gz ($root)/$dir/rootfs2.gz ($root)/$dir/rootfs1.gz
    }

#### Slax

First, download Slax zip (for USB), then extract somewhere (in this case, /live/slax on /dev/sda3)

    menuentry 'slax' {
    	set dir=/live/slax
    	set root=(hd0,msdos3)
    	linux $dir/boot/vmlinuz from=$dir vga=normal load_ramdisk=1 prompt_ramdisk=0 printk.time=0 slax.flags=perch,xmode
    	initrd $dir/boot/initrfs.img
    }

## Using Syslinux and memdisk

Using the memdisk module, the ISO image is loaded into memory, and its bootloader is loaded. Make sure that the system that will boot this USB drive has sufficient amount of memory for the image file and running operating system.

### Preparation

Make sure that the USB drive is properly partitioned and that there is a partition with file system supported by Syslinux, for example fat32 or ext4. Then install Syslinux to this partition, see Syslinux#Installation.

### Install the memdisk module

The memdisk module was not installed during Syslinux installation, it has to be installed manually. Mount the partition where Syslinux is installed to `/mnt/` and copy the memdisk module to the same directory where Syslinux is installed:

    # cp /usr/lib/syslinux/bios/memdisk /mnt/boot/syslinux/

### Configuration

After copying the ISO files on the USB drive, edit the Syslinux configuration file and create menu entries for the ISO images. The basic entry looks like this:

    boot/syslinux/syslinux.cfg

    LABEL some_label
        LINUX memdisk
        INITRD /path/to/image.iso
        APPEND iso

See memdisk on Syslinux wiki for more configuration options.

### Caveat for 32-bit systems

When booting a 32-bit system from an image larger than 128MiB, it is necessary to increase the maximum memory usage of vmalloc. This is done by adding `vmalloc=valueM` to the kernel parameters, where `value` is larger than the size of the ISO image in MiB.[3]

For example when booting the 32-bit system from the Arch installation ISO, press the `Tab` key over the `Boot Arch Linux (i686)` entry and add `vmalloc=768M` at the end. Skipping this step will result in the following error during boot:

    modprobe: ERROR: could not insert 'phram': Input/output error

## See also

- GRUB:
  - https://help.ubuntu.com/community/Grub2/ISOBoot/Examples
  - https://help.ubuntu.com/community/Grub2/ISOBoot
- Syslinux:
  - Boot an ISO image

Category:

- Boot process