8

Can I Install grub on an USB and make it a rescue disk?

Question: Is it safe to run the following commands?

sudo grub-install /dev/sdb    (where sdb is my USB drive)
update-grub2
  • Question: Would I really get a grub menu from USB (provided that it boot first at my BIOS) whenever I cannot boot from my hard disk?
  • Question: Does update-grub2 delete itself from one drive when installing to another, will I boot from hard disk also than from USB, depending on my BIOS options?
Mateo
  • 8,104
Salvador
  • 473
  • This "question" would be better suited for a forum than our Q&A site, as you don't seem to have a specific question here. Please either clarify your question, or delete it. Perhaps the Ubuntu Forums would be a good place for this? – SirCharlo Aug 24 '12 at 19:46
  • 1
    @Mik I decide question 2 – Salvador Aug 24 '12 at 20:05
  • @SirCharlo my questions have been updated – Salvador Aug 24 '12 at 20:12
  • possible duplicate of http://askubuntu.com/questions/23465/installing-grub2-on-one-bootable-usb-stick – user68186 Aug 24 '12 at 20:30
  • 2
    Running grub-install this way would certainly install grub2 to the USB device, however the subsequent update-grub2 would update the grub on the hard drive, not the USB. No harm, it just wouldn't do what you want. In most cases a LiveUSB or LiveCD can be used as a recovery tool since it can be used to re-install grub, configure grub (after chrooting into the hard drive) and for doing a clean install. – fabricator4 Aug 24 '12 at 20:35
  • @mateo_salta Did you made a backup of the other questions? – Salvador Aug 24 '12 at 20:40
  • 1
    It is in the edit history, click on the time next to "edited" – Mateo Aug 24 '12 at 20:41

2 Answers2

15

The question is about installing GRUB on USB drive. Let's start with the questions first:

  1. The command sudo grub-install /dev/sdb (where sdb is my USB drive) should work when booted from the hard drive with USB drive connected. However, since GRUB puts its config files in /boot/grub, where those will go depends on what kind of Ubuntu installation you have in the USB drive.

    • If it is a live USB, the /boot/grub folder includes a loopback.cfg and installing the rest of grub there may have unintended effects.
    • If you have a full installation of Ubuntu in a 8GB or larger USB drive, See more at How do I install Ubuntu to a USB key? (without using Startup Disk Creator), then GRUB should be installed at the time of Ubuntu installation. If for some reason GRUB is not installed, you can mount the USB boot partion (assuming sdb1) and specify where the rest of grub goes by

      sudo mount /dev/sdb1 /mnt
      sudo grub-install –boot-directory=/mnt/boot /dev/sdb
      
  2. Yes, you can get a GRUB menu from USB drive provided you have a full Ubuntu installation in that USB drive.

  3. No, update grub should not delete information from the internal drive. You can control which GRUB will be updated by using sudo chroot /mnt after mounting sdb1 to mnt.

Hope this helps.

user68186
  • 33,360
  • Thanks, now my problem is that my new USB stick of 32 Gb runs very slow, so I am forced to use, if a need it, a LiveCD as the rescue disk, instead of a LiveUsb – Salvador Aug 27 '12 at 17:00
  • You are welcome. I don't know why your full install on 32GB USB is slow. Could you please ask a new question, others who know better may have some answers. Best of luck. – user68186 Aug 27 '12 at 17:05
  • 1
    In the latest grub-install they changed --root-directory to --boot-directory. – John Eikenberry Jul 08 '17 at 20:40
  • Is grub-mkconfig necessary as well or is that handled as part of grub-install --boot-directory? – thom_nic Oct 04 '17 at 13:50
  • I don't think grub-mkconfig is needed unless you want to change the defaults. – user68186 Oct 04 '17 at 20:29
1

Maybe you could, but this isn't the preferred way to do it. The Live USB is already a rescue disk by default. It doesn't make much sense because you would still need to restore/repair GRUB on the target disk. Until you did, you are stuck using the USB for GRUB, which isn't logical.

Best practice is to use a regular Live USB or Live CD, then run
sudo grub-install /dev/DEVICE_NAME_HERE

Code sample copied from @Roland Taylor's answer here(a suggested duplicate).

Tom Brossman
  • 13,111