www.rodneybeede.com "I would love to change the world, but they won't give me the source code" - unknown
 Navigation

Grub 2 for booting ISOs on USB disks - Last Modified 2012-06-14 21:51 UTC - Created 2011-12-16 14:55 UTC

I like being able to boot various Linux distros from USB sticks. It makes it easy to update to newer versions, is faster, and doesn't require using up DVD-R discs. Previously this required extracting the ISO contents to a USB disk and setting up special boot loaders. I have found a new way using grub2 to just copy the unmodified ISO file to the USB stick without extraction.

Prerequisites

Steps

  1. Setup grub2 on your USB key (FAT32 works and possibly NTFS)
    • grub-install --no-floppy --root-directory=/mnt/sdb1/ /dev/sdb
    • You need Grub 2 (version 1.99 or better)
    • Change out /dev/sdb and /mnt/sdb1/ as appropriate
  2. Copy the ISO to the usb key
    • I use e:\boot\isos for my directory
  3. You must configure boot entries for each boot configuration you want. You can't load the ones built-in to the ISO. See my example below.

Example \boot\grub\grub.cfg

menuentry "Ubuntu 11.10 Desktop x86 (toram)" {
	set isofile="/boot/isos/ubuntu-11.10-desktop-i386.iso"

	loopback loop $isofile
	linux (loop)/casper/vmlinuz boot=casper toram iso-scan/filename=$isofile quiet splash noprompt --
	initrd (loop)/casper/initrd.lz
}

menuentry "Ubuntu 11.10 Desktop AMD64" {
	set isofile="/boot/isos/ubuntu-11.10-desktop-amd64.iso"

	loopback loop $isofile
	linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash noprompt --
	initrd (loop)/casper/initrd.lz
}



set isofilename="systemrescuecd-x86-2.4.1.iso"
# Because System Rescue CD's boot loader adds a / when searching as it really likes it in the root of the drive
set isorelativepath="boot/isos/$isofilename"
set isofullpathname="/$isorelativepath"

menuentry "systemrescuecd-x86-2.4.1 (docache setkmap=us)" {
	loopback loop $isofullpathname
	
	linux (loop)/isolinux/rescuecd isoloop=$isorelativepath docache setkmap=us
	initrd (loop)/isolinux/initram.igz
}

menuentry "systemrescuecd-x86-2.4.1 x64 Mode (docache setkmap=us)" {
	loopback loop $isofullpathname
	
	linux (loop)/isolinux/rescue64 isoloop=$isorelativepath docache setkmap=us
	initrd (loop)/isolinux/initram.igz
}

menuentry "System Rescue CD MemTest86+" {
	loopback loop $isofullpathname
	
	linux16  (loop)/bootdisk/memtestp
}

# Not working yet, not sure how to get multiple initramfs working in grub2 like grub1
# See http://savannah.gnu.org/bugs/?35238 which has a pushed fix not yet released
#menuentry "System Rescue CD NTPASSWD" {
#	loopback loop $isofullpathname
#	
#	linux (loop)/ntpasswd/vmlinuz rw
#	initrd (loop)/ntpasswd/initrd.cgz
#	initrd (loop)/ntpasswd/scsi.cgz
#}
#