Page 1 of 1

Installing Grub On USB Flash Memory Rate Topic: -----

#1 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 282
  • View blog
  • Posts: 1,456
  • Joined: 16-May 09

Posted 28 January 2010 - 02:02 PM

This idea came to my mind when I installed windows 7 and it replaced my GRUB with it's own bootloader. I did everything and couldn't start windows 7 with it, so I decided to install GRUB on my usb flash memory. Now when I plug in my flash memory and start the computer, GRUB runs and loads Debian, without it, it boots windows 7 :D

You need to do this from inside a linux system (use a livecd in case you can't boot your linux right now).

You should already know how to partition your usb device and create desired filesystems and also mounting them.
Also, being familiar with GRUB is a must :)
Visit GRUB's manual for making yourself familiar with the environment

All the work is done by the grub-install command, but you have to give it 2 parameters:
  • The root directory to place the images into (a partition on your usb device for GRUB)
  • The device mbr in which the command installs GRUB bootloader
Find out where your usb device is, mine is /dev/sdb. So this is the second parameter for the grub-install we needed. The first one is the place where your original grub images will be placed.

After selecting the partition for GRUB's installation, mount it and run this command:
grub-install --root-directory=/media/disk /dev/sdb

I had mounted my usb device's desired partition in the folder /media/disk, so now the GRUB images are placed inside this directory. After the script is finished, it tells you about the file, as it tells you, check to see if all your devices are listed there, if so, you are all set and ready for the last step.

Last Step:
Now you have to create a menu file for GRUB, which tells the bootloader where to load the kernel from. This is my own menu.lst file which I copied from my installed system to the flash memory:

Change the locations for your own kernel files, also change the root device to the appropriate partition where you installed your system's boot directory.

Now you are all set and ready to use the usb device, double check the menu entries, make sure you put this menu file in your usb device inside the /boot/grub/ directory.
Now reboot the system with your usb connected to it, change the BIOS settings if needed (to boot any usb devices first), and see if it works :)
Note: Test it with virtual environments to make sure everything is correct before leaving your system.
qemu example for testing: qemu -hda /dev/sdb

Hope this could help you out :)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1