Monday 29 June 2015

Booting from a USB stick via grub2

I made a USB stick using unetbootin, on a Linux machine, booted up, changing the boot setting in BIOS to boot from the stick, and yet no luck. The system booted off disk instead.

Thanks to others who have posted on this topic, I was able to boot from the USB stick using grub2. I’m recording what I did here for reference. The first section below gives the commands once I was in the grub2 command line. Below that is information about how to figure out the partition to boot from and what the commands are doing.

The grub2 commands

Using (hd1, mdsdos1) as the example partition, the summary of commands once you are in the grub2 command line:
  • root=(hd1, mdsdos1)
  • chainloader +1
  • boot

The general overview

  • boot up and launch the command mode of grub2
  • figure out what partition represents the bootable USB drive
  • set that partition as the root
  • load the bootloader of the USB stick so it will be used to boot from
  • boot from this loaded bootloader, i.e. the one on the USB stick

The grubby details

  • When you get to the grub2 screen on booting up, press c to get into command mode.
  • Type ls to list the partitions on the system.
  • List the files on the partitions to figure out which one is the USB stick. Your internal system will usually be (hd0,0), so try one of the others first. e.g. ls (hd1, mdsdos1)
  • When you figure out which partition is the one you want to boot from, set it as the root for example root=(hd1, mdsdos1)
  • Then load up the boot loader by typing chainloader +1. This allows the current bootloader (grub2 in this instance) to boot a second bootloader (here, the one you want on your USB stick). See: http://www.linux.com/learn/answers/view/919-what-is-chainloading-and-how-do-it-do-it
  • Type boot to boot from the USB stick.

No comments:

Post a Comment