3

I can manually boot my sole Ubuntu 10.10 install from my USB stick typing the following commands:

set root=(hda0)
linux /vmlinux root=/dev/sda1 ro
initrd /initrd.img
boot

What I was hoping for is to have the USB do it for me. No typing required...?

I followed directions from these urls (most didn't work)

grub on a bootable USB rescue stick

How to install GRUB 2 to USB drive / pendrive

GRUB2 and USB flash drives

How To Recover GRUB2 Linux

and some pretty extensive searching here. There's 10 pages at 50 per page. I did what I could and now turn to the experts.

Summary of steps used to make USB boot to grub2, so far...

mkdir -p /media/GRUB2_RESCU/boot/grub
sudo cp /usr/lib/grub/i386-pc/* /media/GRUB2_RESCU/boot/grub
echo '(hd0) /dev/sda' > /media/GRUB2_RESCU/boot/grubdevice.map
sudo grub-install --root-directory=/media /dev/sdb
sudo grub-mkconfig -o /media/GRUB2_RESCU/boot/grub/grub.cfg

Thank you for your time.

3
  • are you asking that everytime you want to boot in ubuntu live edition without installing it from usb? Commented Dec 1, 2010 at 6:10
  • or do you wanna install Ubuntu on USB and boot from it?
    – wliao
    Commented Dec 1, 2010 at 9:23
  • Out of curiosity, why are you trying to do this? Why don't you just boot from the internal drive directly? What happens when you try using the method you described above? Commented Dec 1, 2010 at 10:33

1 Answer 1

5

The steps you gave are close to working, but let me comment on each step.

mkdir -p /media/GRUB2_RESCU/boot/grub

This is completely correct.

sudo cp /usr/lib/grub/i386-pc/* /media/GRUB2_RESCU/boot/grub

This isn't needed but shouldn't hurt anything (grub-install does this automatically)

echo '(hd0) /dev/sda' > /media/GRUB2_RESCU/boot/grubdevice.map

This also isn't needed, and also shouldn't hurt anything. GRUB2 for the most part doesn't need a device.map anymore.

sudo grub-install --root-directory=/media /dev/sdb

I don't know if this was just a typo when you were writing your question or if this is actually the command you ran, but it should be "--root-directory /media/GRUB2_RESCU/". Otherwise grub will install its modules, and look for its grub.cfg, in /media/boot/grub (which isn't on the flash drive) instead of /media/GRUB2_RESCU/boot/grub/. This could explain why what you tried didn't work.

sudo grub-mkconfig -o /media/GRUB2_RESCU/boot/grub/grub.cfg

This should work, but you'll have to run grub-mkconfig manually every time there is a kernel upgrade to get an updated menu. Instead I would recommend writing a manual grub.cfg which just loads the grub.cfg from your internal drive, like this:

root=(hd0,1)
configfile /boot/grub/grub.cfg

To be sure that this works even when drives are moved around replace

root=(hd0,1)

with

search --set --fs-uuid UUID_GOES_HERE

You can find the UUID with this terminal command:

sudo grub-probe --target=fs_uuid --device /dev/sda1
1
  • I installed OpenSUSE to sda4 and it overwrote my grub2, but my "bootable" USB Drive that I was not too certain about actually worked! Woot! Straight into Ubuntu! Then I used sudo grub-install /dev/sda sudo update-grub and reboot. Done.
    – Habitual
    Commented Dec 1, 2010 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .