7

How do you install Grub2 on a bootable USB stick?

Somewhere I've heard that Grub2 can boot directly from ".iso" images, so I'm hoping Grub2 will make it easy to drag-and-drop several "liveCD" iso images onto a bootable USB stick and try them out.

0

2 Answers 2

4
  1. Install Grub2 on USB drive (replace /USBDRIVE and /dev/sdx with the correct mount point and USB device)

    sudo grub-install --boot-directory=/USBDRIVE/boot /dev/sdx 
  2. Create required directories

    mkdir /USBDRIVE/iso mkdir /USBDRIVE/boot/grub/scripts 
  3. Save this autoiso.cfg script in the /USBDRIVE/boot/grub/scripts directory

  4. Create a grub.cfg file with the following content in the /USBDRIVE/boot/grub directory

    configfile /boot/grub/scripts/autoiso.cfg 

Now you can drag-and-drop several "liveCD" iso images into the iso directory of the USB stick and boot them. The following live systems are supported:

  • grml
  • Parted Magic
  • Slax
  • Tinycore
  • Ubuntu
  • live systems with a loopback.cfg
1
  • none of this works for me. i get a lot of errors from grub-install. Commented Feb 26, 2013 at 18:17
1

If the initialization system will scan hard drive devices, as well as optical media devices, for the root filesystem it seems, you should be able to tweak an existing bootable ISO image to work on any hard drive type device, like a USB memory stick. Ubuntu uses Casper for its bootable install/live ISO images and that looks everywhere for the ISO filesystem it wants to mount. I have succeeded in converting them from plain ISO into a hybrid ISO/IMG file that can be dd'd directly to a USB memory stick, and still be burned to a CD or DVD. I achieved this by appending the kernel (and the memory tester image) to the ISO (so it got larger), assigned a sector location for the stage2 image, modified the GRUB source so all the sectors were built in (directly in stage1 and via a built config for stage2), compiled, and finished the image with stage2 appended, and stage1 replacing sector 0.

However I did this with GRUB legacy (v1). I've since moved over to SYSLINUX for my bootable projects, so I never actually worked out the process for GRUB2. As long as it has a way to set defaults or do a built-in config, or there is a way to reference a config file, this should be doable without having to rebuild the ISO.

This only works for ONE ISO image per USB memory stick. Multiple is plausible. It could be easy if they share the same kernel (e.g. having Ubuntu and Kubuntu on the same device).

I do not know of any drag-and-drop tools. I built mine with a script to be run at a root command shell. I have not packaged this into release project and never intended to. There's no documentation but comments in the "build" script itself, so you're on your own. Feel free to download it to see the exact details of what I did: http://ubuntu.slashusr.org/iso-for-hd-2010-10-11-225024.tar.gz

I last used it to build images for Ubuntu 11.04 which you could look at to see the final product of the script. They are at http://ubuntu.slashusr.org/11.04/ The .map files show the sector layouts.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.