Linux Commands

How to boot from USB using GRUB

GRUB ( Grand Unified Bootloader) is mostly used in the distributions of Linux. Grub is very handy for troubleshooting the system and changing boot arguments. Sometimes the operating system does not boot automatically, we can boot it from a USB using a GRUB. The method to boot from USB using a GRUB is convenient and easy to understand, we will explain this method in detail in this writeup.

How to boot from USB using GRUB

To boot from USB you first need a USB device and download the balenaEtcher application from balenaEtcher. Then using the ISO image file of any distribution of Linux make a bootable USB:

Connect the bootable USB to the USB port of the computer, and open the grub menu by pressing the BIOS menu key, in Ubuntu-based distributions it can be opened by pressing the “Right SHIFT” key.

When the Grub menu appears, press the ESC key or c/C key to enter the Grub console: once you enter it, list down all the available devices using the ls command:

grub> ls

It will display all the hardware devices connected to your computer, our device name is (hd0,msdos5), we will set the device to the root by using the command:

grub> set root=(hd0,msdos5)

Note: In your case the device name could be different. Use the “find” command and “TAB” key to check the files of the attached devices.

After setting the USB to the root, the next task is to locate the bootloader on our USB, for the chainloading.

The readers who don’t know about chain-loaders; some operating systems do not allow multiboot and also they do not have support for the GRUB, for such operating systems, they are loaded with some other operating systems with the help of chain-loaders. To set our USB with the chain load, we will give the path of the boot loader to it:

grub> chainloader /efi/boot/grubx64.efi

Finally, we will boot it from USB using the command:

grub> boot

Conclusion

GRUB is a boot manager which is used to call and manage the operating system on the computer. If the operating system is not booting then it can be booted from the USB using the GRUB. In this write-up, we have discussed the method of booting the operating system from bootable USB using the GRUB. The method is quite easy and needs a bootable USB and some understanding of the commands.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.