Howto: Convert a Gentoo install CD for use on a USB drive

If you've got a small (<1G) USB drive you'd want to use to install Gentoo, the Gentoo LiveUSB HOWTO won't work as the latest minimal/install CD has not got proper vfat support, and you would need atleast a 1G drive for a Live CD.
This HOWTO is for creating a minimal install on a USB drive (>=64M required for x86) using a 2008.0_beta1 minimal install CD image and ext2. Instead you could use a 2007.0 install CD, or even a live CD if you have a large enough USB drive.

You can also skip to the downloads if you don't want to create your own.

Downloading the .iso

You will need to download the minimal install CD from a mirror near you. It will be under releases/your_arch/version_you_are_using/. In this example we will be using a x86 iso.

# wget http://your_mirror.com/releases/x86/2008.0_beta1/install-x86-minimal-2008.0_beta1.iso

Mounting the iso image

To copy the files from the CD we will use a loop device. For this you will need the loop driver (CONFIG_BLK_DEV_LOOP). If you have compiled it as a module, modprobe it first

# modprobe loop

Now mount and copy the files

# mkdir -p /mnt/{usb,cdrom,removable}
# mount -o loop,ro install-x86-minimal-2008.0_beta1.iso

Formatting the USB drive

You will need to create a large enough ext2 partition for the files in /mnt/usb. In this example /dev/sdc is the USB drive we will use. Make sure you use the right drive or you might overwrite something important.

# mke2fs -L "Gentoo USB" /dev/sdc1
# mount /dev/sdc1 /mnt/usb

Copying the files

Now copy the files onto the USB disk.

# cp -a /mnt/cdrom/* /mnt/usb/
# umount /mnt/cdrom

Setup the bootloader

You will need to setup Grub/extlinux on the drive to make it bootable.
On 2008.0_beta1:

# cd /mnt/usb/boot/grub
# rm stage2_eltorito
# cp /boot/grub/{stage1,e2fs_stage1_5,stage2} .
# mv grub.conf menu.lst
# grub
grub> device (hd0) /dev/sdc
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
# cd
# umount /mnt/usb

On 2007.0 and older:

# emerge -na syslinux
# cd /mnt/usb
# mv isolinux/* .
# mv isolinux.cfg extlinux.conf
# rm -r isolinux*
# extlinux -i /mnt/usb
# cat /usr/lib/syslinux/mbr.bin > /dev/sdc
# cd
# umount /mnt/usb


You should now have a bootable USB dongle. You will still probably need to enable booting from USB in the BIOS.

Ready built images

A few pre-assembled USB images.
To install these, if your USB drive is /dev/sdc:

# gunzip -c file_name.gz > of=/dev/sdc

x86 2007.0-r1 - fits on >=64M drive
x86 2008.0_beta2 - fits on >=64M drive
amd64 2008.0_beta2 - fits on >=128M drive

Images by Mrs A. Linnapuomi