Boot your (bootable) USB directly from grub

Long time, and I hit across this one scenario, and yay – we have this blog post here!

Pretty old machine with a Linux installed, and working grub, and I wanted to install another Linux variant! I got my bootable USB drive ready, but the stupid machine was not detecting it during boot-time I guess, as it never had mind to boot from it.

Similar situation can come up when you forgot the BIOS password, making it difficult for you to change the boot order. So here you go!

Let me put in steps, so that easy for someone (or even myself) to copy later!

  1. Insert your USB drive, boot normally, go to Grub command line – This might be probably a click of ‘c’ from the Grub menu! You will be in somewhere like
  2. Type in ls and find out the correct USB drive notation and partition. In my case, it was (hd1, msdos1) You can simply find the correct one by typing in ls (hdx,msdosy)/ or similar
  3. Now we have the partition, lets try booting from it! This is the tricky step, and here you go!
    set root=(hd1,msdos1)
    linux /casper/vmlinuz.efi boot=casper noprompt noeject root=/dev/sdb1
    initrd /casper/initrd.lz
  4. TADA! Here you go! If you see a prompt like

    You have done something seriously wrong 🙂 Take time to go all the way from top till down again, and if it still dont work out, kindly comment!


[Grub] Booting Linux from a faulty grub – rescuing grub_resuce

This would be the most interesting post in the grub series – if you have read the previous ones and you are in the above situation.

* Grub wont show up – shows an error and grub_resuce>
* Cannot do boot repair – as the live disc is booting only in Legacy mode – and UEFI entry for the USB drive is missing from the boot menu [1]
* Linux was successfully installed somewhere on your drive – and you forgot where – and you want to boot that one.

I am personally attaching a few screenshots to add beauty to the steps. These are taken from my Virtualbox – where linux was installed as legacy.
* You would have a grub rescue terminal similar to this one:
Grub rescue
* Find the partition where you installed Linux

grub > ls
(hd0) (hd0,msdos5) (hd0,msdos4)

If your partition is a GPT one. ie OS was installed as UEFI : you would find something like :

grub > ls
(hd0) (hd0,gpt5) (hd0,gpt4)

* Bruteforce ‘ls’ to find your Linux partition:
You should be going like ( in GPT ):

grub > ls (hd0) 
grub > ls (hd0,gpt5)

until you find out something like

grub > ls (hd0,msdos1)
Filesystem type ext2 - Last modiifcation date : blahblah

The ext2 type of partition shows that you have probably hit the right one. To ensure that:

grub > ls (hd0,msdos1)/

ls into partition
Yay ! That looks similar to a standard Linux ‘/’ partition. So you would get that your linux resides in (hd0,msdos1).
* Start the boot procedures.
Before we start – let me copy paste a standard grub:
standard grub
We will have to give roughly similar params to make sure that our grub boots right.

grub> set root=(hd0,msdos1)
grub> linux /boot/vmlinux-3.2.x.x  root=/dev/sda1
grub> initrd /boot/initrd.img-3.2.x.x 
grub> boot

boot params
Hint: You can find out the proper root=/dev/sda1 with a trick.
(hd0,msdos1) means /dev/sda1.
(hd0,msdos2) means /dev/sda2.
(hd1,msdos1) means /dev/sdb1.
(hd0,gpt1) means /dev/sda1.
Thats it ! Hit enter – and you will see your installed linux booting !! Yay!
You will find out how to re-install grub in the next post !

[Grub] Situation : prepared USB drive wont boot in UEFI mode after dd.

Bah ! If you are in that situation when you created the Linux live USB disk using dd as per my previous post[1] and reboot to find out that the UEFI entry for the USB drive is not listed in the bios boot menu – I bet – You would be frustrated.

This situation happened almost a dozen times to me – specifically while using debian-7.2-kde-live.iso. Believe me, this can be tackled as far as you are getting the grub_rescue> terminal on reboot.

You can move forward with the installation – that would be a legacy mode installation and of course – you will have to see a grub_resuce terminal once you finish installation.

* Prepared USB drive wont show up as a UEFI entry in the boot-menu ( F10 while booting )
* Linux installed in legacy ( no UEFI == Legacy ) – reboot greets you with grub_rescue:
* Reboot shows “Invalid media : blahblah” or something and a grub_resuce terminal is seen.

Fix :
* You can boot directly from the grub_rescue terminal !! Find out in my next blog post.


[Grub] Creating a UEFI bootable Linux USB drive using dd

First things first, you need to make your USB drive bootable in UEFI. You should :

  1. Plug in your pendirve ( minimum 4 Gig )
  2. Give
     $ sudo fdisk -l 

    Find out your USB drive mount name from the output. Hint : You can always check for the drive size and spot that one out. The above command would give something similar to :

    # sudo fdisk -l
    Disk /dev/sdc: 15.9 GB, 15854469120 bytes
    255 heads, 63 sectors/track, 1927 cylinders, total 30965760 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x094a46d6

    You will figure out that /dev/sdc corresponds to your pendrive. For the ease, I would continue with the assumption that /dev/sdc is your USB drive.

  3. Open terminal, move to the place where you have your iso file ready
  4. Use dd command to clone the iso to the pendrive
    $ sudo if=ubuntu14.iso of=/dev/sdc
  5. The cloning will take few minutes depending on the speed of your pendrive. Once finished, give the final step :
    $ sync
  6. That’s it ! You are ready with your UEFI bootable pendrive ! Now restart the system – press F9 or something similar to change the boot order and select :


    or something similar from the boot menu and boot!