Almost every modern computer has a dedicated menu to choose where from should the system boots. If not, there is an option in BIOS/UEFI to change that. But what if both options failed for some reason?

One of my old computers runs Linux with GRUB as a bootloader. I use it from time to time, but one day the filesystem crashed and even fsck couldn’t repair it. I prepared USB stick with the new system, but I couldn’t boot from it – BIOS was restoring the booting order on every reboot. Moreover, ever since I installed GRUB, the shortcut to summon booting device selection stopped working.

I had an opportunity to learn how to boot from USB using GRUB.

How to boot from USB using GRUB

I assume that you already have a bootable USB drive with your favourite Linux distro. If not, you can use a tool called Unetbootin to create a bootable USB drive. In this case, I use a Ubuntu distro.

If you have your bootable USB drive, insert into the computer.

Boot from proper device

When the GRUB screen appear, press C or ESC to go to the GRUB console. You should see the grub> prompt.

First, check if GRUB detects your USB drive. Type command ls too see available devices.

grub> ls
(lvm/ubuntu-vg-swap_1) (lvm/ubuntu--vg-root) (hd0) (hd0,msdos1) (hd1) (hd1,gpt2) (hd1,gpt1) (cd0)
Screen from the GRUB console presenting output of ls command.
The output of ls command in GRUB console.

GRUB recognize my USB stick as (hd0,msdos1). I know it because I recently formatted it and created MS-DOS (FAT) partition.

Now, change the root to this device.

grub> set root=(hd0,msdos1)

I can check if it’s a proper device. By using the command find and pressing TAB key, I can preview the list of files on it.

Next step is to locate the bootloader on USB stick to chain-load. In my case, the path to the bootloader is /efi/boot/grubx64.efi. You can use TAB to invoke auto-completion and type the path faster.

grub> chainloader /efi/boot/grubx64.efi
Screen from the GRUB console presenting preparation for chainloader command.
Screen from the GRUB console where I executed chainload command.

To invoke new bootloader, run command boot.

grub> boot
GRUB booted from the SB drive.
GRUB booted from the USB drive.

Summary

This process doesn’t look so complicated. However, it took me almost 2 hours before I finally figured it out. I tried different ways to fix filesystem first, but starting from scratch was the easiest one. Fortunately, I hadn’t had essential data there, but it showed that it’s worth to have a backup of your most important files. You have it, right?

Resources