Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
are you asking that everytime you want to boot in ubuntu live edition without installing it from usb? –  FOSS DIVERSER Dec 1 '10 at 6:10
    
or do you wanna install Ubuntu on USB and boot from it? –  wliao Dec 1 '10 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? –  Jordan Uggla Dec 1 '10 at 10:33
add comment

1 Answer

up vote 4 down vote accepted

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
share|improve this answer
    
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 Dec 1 '10 at 22:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.