Linux – Howto install and configuring grub2 on a USB thumb drive


I'm wanting to play around with grub2 with linux on a thumb drive.

My host OS is Kubuntu.

grub-install allows you to write the grub bootloader to the MBR of a disk which is great.
However, uodate-grub generates grub entries from /etc/grub.d and /etc/default/grub
There doesn't appear to be a way to generate the grub.cfg from a source other than /etc
and write it to anywhere other than /boot/grub/grub.cfg

What's the general approach to generating a grub.cfg for a disk that is not on the running system?

Best Answer

Assuming you're willing to boot an ISO image, I managed to find this blog post. In brief:

  1. Create some sort of Linux partition on the USB disk. ext2 should do, if you don't want the journal to take up excess space.

  2. Mount the partition.

  3. Run this command: grub-install --force --no-floppy --root-directory=MOUNT /dev/sdX. This will install GRUB2 under the mounted directory (here, MOUNT) and write the MBR on /dev/sdX (MOUNT's device).

  4. Goto MOUNT/boot/grub and edit grub.cfg.

Then just edit the file as normal. In the linked post, the author intends to boot ISO images. So, he used this:

menuentry "Ubuntu 10.10 Desktop i386" {
    loopback loop /ubuntu-10.10-desktop-i386.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.10-desktop-i386.iso noeject noprompt splash --
    initrd (loop)/casper/initrd.lz
Related Question