Creating a Bootable USB Stick That Can Still Be Used as Normal Storage
As someone who daily drives rolling release operating systems, having a bootable USB stick with a live install of Debian is essential. It has saved reverting broken packages and making my device bootable again at least a couple of times. However, creating a bootable USB stick usually uses the entire storage of the USB stick, which seems unnecessary given that USB sticks easily have 64GiB or more these days while live ISOs still don’t use more than 8GiB.
In this how-to, I will explain how to create a bootable USB stick, that also holds a FAT32 partition, which allows the USB stick used as usual.
Creating the partition partble
The first step is to create the partition table on the new drive. There are several tools to do this, I recommend the ArchWiki page on this topic for details. For best compatibility, MBR should be used instead of the more modern GPT. For simplicity I just went with the GParted since it has an easy GUI, but feel free to use any other tool. The layout should look like this:
Type │ Partition │ Suggested size
──────┼───────────┼───────────────
EFI │ /dev/sda1 │ 8GiB
FAT32 │ /dev/sda2 │ remainder
Notes:
- The disk names are just an example and have to be adjusted for your system.
- Don’t set disk labels, they don’t appear on the new install anyway and some UEFIs might not like it on your boot partition.
- If you used GParted, create the EFI partition as FAT32 and set the
esp
flag.
Mounting the ISO and USB stick
The next step is to download your ISO and mount it. I personally use a Debian Live ISO for this.
To mount the ISO, use the loop
mounting option:
mkdir -p /tmp/mnt/iso
sudo mount -o loop /path/to/image.iso /tmp/mnt/iso
Similarily, mount your USB stick:
mkdir -p /tmp/mnt/usb
sudo mount /dev/sda1 /tmp/mnt/usb
Copy the ISO contents
To copy the contents from the ISO to the USB stick, use this command:
sudo cp -r -L /tmp/mnt/iso/. /tmp/mnt/usb
The -L
option is required to deference the symbolic links present in the ISO, since FAT32 does not support symbolic links.
Note that you might get warning about cyclic symbolic links. Nothing can be done to fix those, except hoping that they won’t cause a problem. For me this never was a problem though.
Finishing touches
Umnount the ISO and USB stick:
sudo umount /tmp/mnt/usb
sudo umount /tmp/mnt/iso
Now the USB stick should be bootable and have a usable data partition that can be used on essentially every operating system. I recommend testing that the stick is bootable to make sure it actually works in case of an emergency.