Use GRUB2 to Boot ISOs off a Flash Drive

Use GRUB2 to Boot ISOs off a Flash Drive

I will soon need to build a few new PCs that do not have optical drives (one will be a firewall, for example). They do not need the drives for day-to-day usage but I do need to get an OS on them. Since virtually all consumer boards now have USB and I have piles of unused flash drives laying around I decided not to spend the money on an external drive and go the flash drive route.

Here are the steps I took to get my Linux ISOs to boot off a USB flash drive. For these exact steps to work you will need an existing Linux installation (a LiveCD will work just fine).

  1. Create a new, formatted partition big enough to store your ISOs. I am using EXT4 but any filesystem supported by GRUB2 will work. I prefer to use GParted for this.
  2. Mount your new partition. Most Linux desktop distributions will do this automatically for you if you just unplug the device and plug it back in.
  3. Install GRUB2: grub-install --force --no-floppy --root-directory=[path partition was mounted] /dev/sdX where X is the flash drive.
  4. Copy over any ISOs you want to be able to boot to the root of your new partition.
  5. Create [path partition was mounted]/boot/grub/grub.cfg and add the lines

    set timeout=5
    set default=0

  6. In [path partition was mounted]/boot/grub/grub.cfg add any of the following example entries for your favorite distributions:

    menuentry "Ubuntu 10.10 Desktop i386" {
    loopback loop /ubuntu-10.10-desktop-i386.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.10-desktop-i386.iso noeject noprompt splash --
    initrd (loop)/casper/initrd.lz

    menuentry "Ubuntu 10.10 Server i386" {
    loopback loop /ubuntu-10.10-server-i386.iso
    linux (loop)/install/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.10-server-i386.iso noeject noprompt splash --
    initrd (loop)/install/initrd.gz

    menuentry "Darik's Boot And Nuke" {
    loopback loop /dban-2.2.6_i586.iso
    linux (loop)/DBAN.BZI nuke="dwipe" iso-scan/filename=/dban-2.2.6_i586.iso silent --

    menuentry "Memtest 86+" {
    linux16 /memtest86+.bin

I could not, for the life of me, get any Windows ISOs to boot using GRUB2. On top of that I came across a number of people trying to do the same thing whom all failed. If anyone gets this working please post in the comments. I may be able to chainload into another boot loader but that is for another day.


Update 2011.02.18
I found this. It may be nothing but it also may be a jumping off point from which to boot from a Windows ISO.

Update 2021.06.16
I finally figured out how to get the Windows installer to boot from a USB flash drive. Thank you to Doc in the comments for kicking me off in the right direction!

  1. First create an NTFS partition. I made mine a second 8GB partition which fit everything comfortably.
  2. Download the Windows 10 ISO from Microsoft. (I know it feels dirty but Microsoft is offering this for free and legit so why not take advantage?)
  3. Copy the entire contents of this ISO onto your new NTFS partition (not the ISO itself).
  4. Add the following to [path partition was mounted]/boot/grub/grub.cfg

    menuentry "Windows 10" {
    set root=(hd0,msdos2)
    insmod ntfs
    insmod chain
    ntldr /bootmgr

Note the line set root=(hd0,msdos2). msdos2 must be set to whichever partition you copied the Windows 10 files to (counting starts at 1, not 0). Also note this is still using MBR, not GPT/UEFI. Maybe I will update with that at a later date but it should not be too hard to figure out.

You will need to disable Secure Boot for any of this to work.

3 thoughts on “Use GRUB2 to Boot ISOs off a Flash Drive

  1. Nick, you are a scholar and a gent. Thank you so much for posting the syntax for the Ubuntu Server ISOs. I’ve been struggling with this all day.


  2. Windows 7 install can boot off a usb drive, if you use grub, and make the first partition 5+ GB NTFS with the entire windows DVD on it.

    title Windows 7 SP1 Install
    makeactive (hd0,0)
    find –set-root –ignore-floppies /bootmgr
    chainloader /bootmgr

  3. I’ve installed XP and 2003 Server from iso files using the firadisk driver. My USB has GRUB2 as main loader for Linux iso booting, and chaining grub4dos it can be made possible.

    I’ve actually booted an 2008 server (not R2) from an iso, but have yet to install it successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *