Booting a Linux operating system from removable USB media can be extremely useful for system recovery, backups, hardware testing, partitioning, data recovery, and more. The GRUB bootloader included with most Linux distributions offers an incredibly flexible way to load Linux kernels from all kinds of devices.
In this comprehensive 3500+ word guide, we will dig into the technical details of booting via USB with GRUB. Follow along as I share my insider knowledge as a Linux system engineer to break down the boot process, troubleshooting complex issues, tips & tricks for multi-boot setups, and more.
An Overview of the Linux Boot Process
Before jumping into the steps to boot Linux from a flash drive, it helps to understand what‘s happening behind the scenes. Here is a quick overview of the high-level boot process on most Linux systems:
-
BIOS/UEFI Initialization: Performs a power on self test and initializes devices.
-
Bootloader Execution (GRUB): Presents a boot menu and loads the Linux kernel + init RAM disk.
-
Kernel Initialization: Decompresses init RAM disk, mounts root filesystem, starts init process.
-
Init Daemon: Starts essential userspace services via systemd/initd, launches login prompt.
The bootloader stage is what allows us to bootstrap Linux from all kinds of storage media, including HDDs, SSDs, CDs, DVDs, and flash drives.
On Linux, the most common bootloader is the *GRand Unified Bootloader (GRUB)**. GRUB was specifically designed to make booting multiple OSes easy while offering maximum flexibility in terms of supported hardware.
Next we will look at how BIOS versus UEFI firmware impacts the boot process.
BIOS vs UEFI Booting
Traditionally, x86 PCs used the Basic Input Output System (BIOS) firmware standard to initialize hardware and boot devices. The BIOS boot process relied on the Master Boot Record (MBR) partitioning scheme to access bootloader code on storage devices.
However, modern systems increasingly use the newer Unified Extensible Firmware Interface (UEFI) standard instead. UEFI replaces the antiquated 16-bit BIOS and adds many features like:
- 64-bit processor support
- Secure Boot capabilities
- Graphical interface
- Network stack
- Device drivers
When it comes to booting Linux from USB, it is important to know if your system uses BIOS or UEFI firmware. Some key differences between them include:
Feature | BIOS | UEFI |
---|---|---|
Boot mode | Legacy/BIOS | UEFI |
Boot device order | Configurable device priority | Explicit boot entries |
Storage format | MBR partitions | GPT partitions |
Partition size limit | 2TB | 9.4 ZB |
Bootloader location | Master boot record | EFI system partition |
As we can see, a UEFI-based system expects to find the bootloader files on a special EFI system partition (ESP) formatted as FAT32. The ESP contains .efi
applications responsible for loading the OS kernel.
The GRUB bootloader supports both BIOS and UEFI systems. However, you must ensure that your USB drive is formatted properly for the target computer‘s firmware type. We‘ll cover setting up both types of USB drives.
With that background out of the way, let‘s move on to creating our bootable USB key.
Step 1: Prepare the Bootable USB Drive
The first order of business is formatting our flash drive to contain all the files necessary to boot Linux. This requires a couple of steps:
-
Acquiring an ISO file for your desired Linux distribution.
-
Writing the ISO contents onto the USB stick depending on the target system.
Let‘s break these down in detail.
Downloading the Linux Distribution ISO
You likely already have an .iso
disk image file for your Linux distro of choice from its official website. For example, Ubuntu, Fedora, Debian, and CentOS all provide .iso
files to write to DVDs/USBs.
On Linux and BSD systems you can also create .iso
files from the command line via utilities like dd
, but downloading pre-made ones is easier.
Some common Linux distribution ISOs to download include:
- Ubuntu Desktop
- Fedora Workstation
- Debian Live
- CentOS Minimal
- Gentoo Minimal Install
- SuSE Linux Enterprise
- Arch Linux
The ISO should be less than 4 GB in size to fit on common USB flash drives. Copy or download it onto the machine where you will be creating the USB.
Writing the ISO to USB via DD (BIOS)
On Linux, the standard way to write an OS install ISO to a USB is using the powerful dd
utility. dd stands for data duplicator and copies files at the block-level.
Let‘s walk through an example using dd
to write Ubuntu server to a USB on Linux:
- Insert your USB flash drive and determine its device path using
lsblk
:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 117.2G 0 part /
└─sda2 8:2 0 2G 0 part [SWAP]
sdb 8:16 1 14.5G 0 disk
└─sdb1 8:17 1 14.4G 0 part
Here we see the drive as /dev/sdb
. Make sure to verify no critical data is on it!
- Copy the ISO contents byte-for-byte to the drive using
dd
:
$ sudo dd if=ubuntu-20.04.1-live-server-amd64.iso of=/dev/sdb bs=4M status=progress
This duplicates the ISO onto /dev/sdb
, our USB drive. The status flag shows dd‘s progress.
- Once complete,
sync
to flush I/O buffers and verify successful copy withlsblk
:
$ sync
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 117.2G 0 part /
└─sda2 8:2 0 2G 0 part [SWAP]
sdb 8:16 1 14.5G 0 disk
├─sdb1 8:17 1 256M 0 part
└─sdb2 8:18 1 14.2G 0 part
We can see the drive now has a valid partition table matching the ISO structure. Our USB is complete!
This simple dd
copy method works for BIOS/legacy boot mode using MBR drives. But for modern UEFI systems, a different utility is recommended.
Writing the ISO for UEFI Systems with Rufus
While the dd
technique we just saw gets the job done in BIOS mode, UEFI booting requires an extra partition with a FAT32 filesystem. The handy multi-platform tool Rufus makes this really easy under Windows and Linux.
Follow these steps to use Rufus to create a compatible UEFI USB drive:
-
Launch Rufus and select your downloaded
.iso
under the disc image option. -
Configure Rufus for UEFI boot partition creation:
- Partition scheme = GPT
- Target system = UEFI
- File system = FAT32
-
Select your USB flash drive under Device.
-
Click Start. Rufus will format the drive with a FAT32 ESP marked as bootable via UEFI.
Using Rufus ensures maximum compatibility for UEFI systems like modern laptops and desktops running Windows 8+ or Linux. The FAT32 ESP will contain \EFI\BOOT\bootx64.efi
, responsible for actually loading GRUB after firmware initialization.
Now that you have your USB drive for either BIOS or UEFI booting prepared, we can discuss entering the system boot menu.
Step 2: Accessing the Boot Menu
With our bootable Linux USB key ready, we have to set the computer to try booting from it via the UEFI/BIOS settings screen.
The exact key presses to enter setup differs between manufacturers, but common options include:
- Spamming ESC, F1, F2, F8, F10, F11 or F12 after powering on
- Holding SHIFT during reboot
- Windows Advanced Restart > UEFI Firmware Settings
- Linux command
reboot bios
Once in your firmware boot menu:
- Navigate to the Boot, Boot Order, or General tab.
- Select your plugged in USB device as the first boot device priority.
- Save changes and exit.
During the next boot, the computer should attempt initializing from the USB before any internal drives.
If configured correctly, you should see the GRUB bootloader display its main menu instead of your normal OS. We cover what to do at this point next.
Step 3: Navigate the GRUB Menu
Assuming your boot media was written properly and selected in the boot order, you will be presented with the GRUB boot menu. This initial menu displays splash animations and options for the various operating systems found on the drive.
When booting Linux from USB, you will generally have at least two choices here:
-
Boot Normally: Starts up the live Linux system directly. Useful if you just need to access rescue tools without modifying any local system files.
-
Entering Rescue Mode: Drops to a GRUB rescue prompt allowing full control to manually load Linux, alter configs, fix boot issues, etc.
We want to enter rescue mode to fully take advantage of GRUB‘s flexibility. Select the appropriate "Advanced Options" entry and press e
to access the editor.
Step 4: Set root and Chainload Bootloader
At the GRUB editing interface, we want to change two key values:
- The GRUB root device
- The Linux kernel / initrd to chainload
First, use the ls
command to list devices seen by GRUB. Identify your USB drive – it will start with (hd
, fs
, etc. Mine is (fs0)
:
grub> ls
(memdisk) (hd0) (hd1) (fs0)
Next, set root to use your USB‘s GRUB install with set root
:
grub> set root=(fs0)
Finally, set the Linux kernel and init ramdisk paths on your USB to boot:
grub> linux (fs0)/boot/vmlinuz boot=casper iso-scan/filename=/ubuntu-20.04.iso ro quiet splash
grub> initrd (fs0)/boot/initrd
With the root device configured and kernel + initrd chained to load, type boot
to hand-off execution to the USB‘s bootloader. This will proceed with booting Linux as normal.
And that‘s it! By redirecting GRUB to use our USB drive‘s GRUB installation we can cleanly bypass the installed OS and load Linux directly from our media.
Troubleshooting Issues
Despite our best efforts, you may encounter issues getting Linux to boot properly from the USB key. Here are some common obstacles and potential solutions:
Missing GRUB menu
If your USB completes firmware initialization but immediately boots Linux without a GRUB screen, you likely wrote the media for BIOS mode and are attempting UEFI or vice versa.
Format the USB drive correctly via dd
or Rufus matching the target computer‘s boot method.
Early termination, device not found
Seeing error: early termination, device not found
means GRUB can‘t find the next component in the boot process. Verify root is set to the proper USB disk and partition with updated linux
+ initrd
paths.
No bootable device found
With no response after selecting the USB as boot priority, the motherboard still does not detect it as valid boot media. Try re-creating the disk or using the other tool between dd
and Rufus.
Operating system missing
If Linux begins booting via GRUB but then throws OS not found or kernel panic errors, either the USB was not populated correctly or requires extra boot options. Pass nomodeset
, acpi_osi=Linux
, etc to troubleshoot.
As we can see, most issues stem from either misconfigured BIOS/UEFI settings, incorrect media creation, or Linux kernel arguments. Triple checking for consistency across steps is key.
Tips for Multi-Boot Setups
While I‘ve focused on booting Linux distributions, the same GRUB menu allows chainloading between multiple operating systems installed across drives and partitions.
A Linux SSD alongside Windows on another drive is a common multi-boot setup. Here the Linux GRUB instance acts as the primary boot manager.
From here Windows boot files can be called directly via their partition path. Some tips when multi-booting:
- Use
os-prober
to auto-detect other OSes to add - Chain Windows BOOTMGR via
drive\boot\bootmgfw.efi
- Create custom GRUB entries with label, icon, etc
- Hold SHIFT after BIOS to access Grub temporarily
- Change default OS booted after timeout
Pay special attention to passing any necessary options like UEFI or legacy mode for Windows.
Integrating Other Bootloaders
The Linux world has historically had many competing bootloader projects. While GRUB rose to prominence on Linux, others you may encounter include:
-
LILO: The original but outdated Linux loader. Adds
.lilo
section to MBR. -
Syslinux: Lightweight BIOS/UEFI loader often used on rescue media.
-
Gummiboot/systemd-boot: Systemd‘s native UEFI bootloader, leverages EFI stubs over MBR.
-
coreboot: Open source system firmware, replaces proprietary BIOS.
Most modern Linux distributions have settled on GRUB as the standard. But since all bootloaders access kernel through multiboot standard, they can interoperate.
For example, booting Linux with Systemd‘s systemd-boot
and chainloading to GRUB modules is a robust possibility.
Conclusion
I hope this guide served as a deep dive into everything involved with preparing bootable USB media to load Linux via the GRUB bootloader. We covered key concepts like:
- The components of a Linux boot process
- Support for BIOS versus UEFI systems
- Tools for writing ISO files like
dd
and Rufus - Accessing firmware boot menus
- Configuring GRUB rescue mode properly
- Troubleshooting boot issues
- Multi-OS considerations
- Interoperation with other bootloaders
Having access to a Swiss Army knife USB key that can boot Linux on any computer via GRUB opens up many useful troubleshooting, repair and system maintenance scenarios. Get out there, start building multi-boot thumb drives catered to your needs, and take back control of your hardware!
Let me know in the comments if you have any other questions. Thanks for reading!