Skip to content

Instantly share code, notes, and snippets.

@nitingupta910
Created March 19, 2025 19:40
Show Gist options
  • Save nitingupta910/90f6aabb38641124b6e82c64c3ab247e to your computer and use it in GitHub Desktop.
Save nitingupta910/90f6aabb38641124b6e82c64c3ab247e to your computer and use it in GitHub Desktop.
Create USB with multiple Linux distro installers

Steps to setup a USB drive for use as installer for multiple Linux distributions without using any third-party tools. This is to avoid more convenient but potentially malware Ventoy.

IMPORTANT: Use fdisk -l and dmesg to identify the USB disk to use. Steps below assume /dev/sda as the USB disk to target. If you pick a wrong disk, you would LOSE ALL DATA on that disk.

USB Setup

# Create two partitions
sudo fdisk /dev/sda
1 - EFI System (type=1): size=+1G
2 - Linux: size=rest of the disk (default from fdisk)

# Format
sudo mkfs.vfat -F 32 /dev/sda1
sudo mkdfs.ext4 /dev/sda2

# Setup grub on /dev/sda1
sudo mkdir -p /mnt/usb
sudo mount /dev/sda1 /mnt/usb
sudo grub-install --target=x86_64-efi --removable --boot-directory=/mnt/usb/boot --efi-directory=/mnt/usb

# Grub config
sudo mkdir -p /mnt/usb/boot/grub
## (see grub cfg below)
sudo vi /mnt/usb/boot/grub/grub.cfg

# Copy ISO files to /dev/sda2
sudo umount /mnt/usb
sudo mount /dev/sda2 /mnt/usb
sudo mkdir /mnt/usb/iso
cp ~/Downloads/ubuntu-desktop.iso /mnt/usb/iso/
cp ~/Downloads/ubuntu-server.iso /mnt/usb/iso/

Grub config file

(With /dev/sda1 mounted, edit /mnt/usb/boot/grub/grub.cfg)

Get UUID of partition with ISO files:

blkid /dev/sda2

Use this blkid in the grub config file below:

set timeout=30
set default=0

# Find the second partition by its filesystem label or UUID
# search --set=root --label YOUR_SECOND_PARTITION_LABEL
# OR use UUID (more reliable)
search --set=root --fs-uuid <<<<YOUR_SECOND_PARTITION_UUID>>>>

menuentry "Ubuntu Desktop" {
    set isofile="/iso/ubuntu-desktop.iso"
    loopback loop $isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
    initrd (loop)/casper/initrd
}

menuentry "Ubuntu Server" {
    set isofile="/iso/ubuntu-server.iso"
    loopback loop $isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
    initrd (loop)/casper/initrd
}

# Add more entries as needed

Unmount

sudo umount /mnt/usb
sudo sync

Booting

On Dell laptops, press F12 for one-time boot menu. Booting with USB-C does not seem to work, so use USB-A for booting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment