Booting Ubuntu’s Minimal CD iso from Grub2

Today I got me a used Acer Aspire One ZG5. It came with preinstalled Ubuntu, but also with the previous owner’s data that they obviously wished to be wiped first.

The ZG5 doesn’t have an optical drive, and I don’t have any thumbdrives bigger than 256 MB, so reinstalling took a bit of creativity.

The obvious choice might have been to get an installation iso smaller than 256 MB, stick it to a thumbdrive and proceed from there. But I figured, I already have Grub and schtuff from the previous installation on the disk, so why not make use of it?

The Boot & Install Ubuntu from the Grub Rescue Prompt HOWTO on Ubuntu Forums looked like the way to go, but I wanted to use the toram option to make unmounting of the iso work. As the ZG5 (by default) only has 512 MB of memory, cramming an entire CD’s worth of data into it wouldn’t be possible, so I grabbed the minimal CD image of Precise, which currently is 24,1 MB. To do this I recovery-booted the pre-existing installation and used wget to download the image into /root.

I then rebooted and went to the Grub commandline. Just as in the Howto, I set the Grub modules path, loaded necessary modules (no Microsoft filesystems needed, the old / was ext2), set the loopback and root.

set prefix=(hd0,1)/boot/grub
insmod linux
insmod loopback
insmod iso9660
loopback loop (hd0,1)/root/mini.iso
set root=(loop)

Next was the linux commandline. The mini CD doesn’t have casper and location of files differs slightly from the Live CD. I also added the toram parameter:

linux /linux iso-scan/filename=/root/mini.iso noprompt noeject toram
initrd /initrd.gz

Then just

boot