ISO to USB no wasted space
Difficulty: ★★☆☆☆
Original topic on the archived forum. My notes on ISO to USB no wasted space
Manjaro ISO
From time to time the question is raised on how an ISO is written to a USB stick, especially large capacity USB sticks.
Why can’t I use the remaining space on my 32GB USB?
This is because Manjaro ISO is a ISO9660 CD-ROM file system and this filesystem is immutable: you cannot change it. As such a 2GB ISO makes it impossible to use the excess space for anything - it just sits there unused.
So what can we do?
The choices
- ventoy
- Multi Boot USB
1. ventoy
ventoy is a set of small binaries compiled from various open source projects - most notably grub and exfat.
It is also available for Windows from the ventoy web
It installs a bootloader for EFI and MBR and formats the remaining part of the device using exfat.
Copy your ISO files to the partition and boot your system from the stick. ventoy locates all ISO files and presents them in a consistent manner.
Then you select the ISO to boot. It is even simpler than below method.
Install the package from the repo
$ pamac install ventoy
When done run the script to display your options or use the GUI (TIP: use the option menu to divide the stick’s storage space)
$ ventoy
Locate your usb stick
$ lsblk
Then initialize the stick (one time operation)
$ sudo ventoy -i /dev/XdY
When done, the disk is available in your file manager - copy your ISO files to the stick.
Eject the stick using the eject button in your file manager and wait. Depending on the number of ISO, the speed and quality of your USB disk it will take a long time to complete. Have patience … patience - only when the USB disappears from your file manager you can remove it.
You can drop a Windows ISO to the stick - it works equally well.
When the app is updated you can update your stick without reformatting it
$ sudo ventoy -u /dev/sdy
While ventoy makes it possible to use the stick for storage as well as boot you cannot access the device while an ISO is booted.
If you plan to use an ISO as a leave-no-trace tool - consider leaving space to hold an extra partition for persistence data. If this is your plan then it is a good idea to have ventoy use the GPT partition schema. To initialize the stick using GPT and leaving 1GB free space for persistence (adjust to your needs - size is MB)
$ sudo ventoy -i -g -r 1024 /dev/sdy
Create the storage partition using a partitioning tool when ventoy is done.
Example for an encrypted storage partition (note the partition is the third on the stick)
sgdisk --new 3::: --typecode 3:8300 /dev/sdy
wipefs -af /dev/sdy3
cryptsetup --type luks2 --tries 5 --use-urandom luksFormat /dev/sdy3
cryptsetup open /dev/sdy3 cryptroot
mkfs.f2fs /dev/mapper/cryptroot
cryptsetup close /dev/mapper/cryptroot
2. Multi Boot USB stick
With the script it is insanely easy to create a stick that boots a variety of ISOs. And Arch based ISOs work extremely well - including Manjaro.
You can download the collection of scripts as an archive or your can clone from Github - what ever you prefer. This guide uses git.
Install git - if you don’t have it
$ sudo pacman -Syu git
Clone the repo
$ git clone https://github.com/aguslr/multibootusb
Cloning into 'multibootusb'
...
Navigate into the repo folder
$ cd multibootusb
To get an idea of what the script is doing
$ ./makeUSB.sh -h
Script to prepare multiboot USB drive
Usage: makeUSB.sh [options] device [fs-type] [data-size]
device Device to modify (e.g. /dev/sdb)
fs-type Filesystem type for the data partition [ext3|ext4|vfat|ntfs]
data-size Data partition size (e.g. 5G)
-b, --hybrid Create a hybrid MBR
-c, --clone Clone Git repository on the device
-e, --efi Enable EFI compatibility
-i, --interactive Launch gdisk to create a hybrid MBR
-h, --help Display this message
-s, --subdirectory <NAME> Specify a data subdirectory (default: "boot")
The default fs-type is vfat .
The data-size is not defined. The data-size option is only useful if you want to set aside space for a persistent storage partition. The storage space for ISO files is then limited to the specified size of e.g. 5G.
When you use the data-size option - the remainder of the USB is left untouched. To be able to actually use the space you will need to manually create a partition using the remaining space. One example is a LUKS encrypted container for your sensitive data.
Remove the USB stick and list devices
$ lsblk -la
Insert the USB stick and do it again - note the added device and create the the USB stick - using vfat makes the device visible in Windows too.
The following commands will assume your device is /dev/sdy
- replace the device name with the device name from your system.
NOTE : The script prints each command to the console before executing - so you can follow what the script is currently doing.
The following creates a hybrid USB stick using vfat
$ sudo ./makeUSB.sh -b -e /dev/sdy vfat
To create a USB stick only for Linux, use ext4 instead
$ sudo ./makeUSB.sh -b -e /dev/sdy ext4
Download a Manjaro ISO, open the device in your file manager and copy the iSO to the folder /boot/isos on the USB stick. Use the eject function of your file manager or the terminal.
IMPORTANT : Do not remove the device until all buffers are flushed to disk. If you want to make sure the ISO is written correctly: *verify the checksum of the resulting ISO on the USB stick.
$ mkdir ~/usb-multiboot
$ sudo mount /dev/sdy3 ~/usb-multiboot
$ cp ~/Downloads/manjaro*.iso ~/usb-multiboot/boot/isos
$ sync
$ sudo umount ~/usb-multiboot
$ sync
- Boot your system from the USB stick
- Select Multiboot >
- Wait while the configuration is read. (The more ISOs, the longer the read time)
Tips
The stick presumably supports more than 100 different distributions - so the Multiboot > menu takes a while to load - because of the dynamic nature of including the ISOs.
To speed up the initial USB Multiboot configuration - you can remove folders from /boot/grub/mbusb.d/ you don’t intend to use.
Issues
The project is archived on github - which means no maintenance - but grub is grub - the only issue would be that a given ISO is unsupported.
Then it should be fairly easy to add.