This document describes how to create a Gentoo Live USB. It's very similar to the Ubuntu Live USB process we described on an alternate page.

Introduction

Booting from a USB device is ofter faster than from CD and USB drives are easier to carry. You should know why you want and or need this. We used Gentoo 2008.0 as our image for booting and a Gentoo system for building on.

Prepare your System

Prepare you build system for the work we'll be doing. Download a copy of the latest Gentoo Live CD ISO, at this time 2008.0, store that ISO somewhere nice. Alternatively one could choose to use a different ISO image, maybe the minimal (which will fit on a 256MiB USB drive!). Plug in the USB Key device, in this article this is /dev/sda, adjust as necessary. Make a partition on the USB device that is at least 800MiB and format with ext2.

curl http://bouncer.gentoo.org/fetch/gentoo-2008.0-livecd/x86 > /tmp/livecd.iso
mkdir -p /mnt/gentoo_cd
mount -o loop /tmp/livecd.iso /mnt/gentoo_cd

cfdisk /dev/sda
mkfs.ext2 -b1024 -m0 -L'Gentoo Live USB' -O sparse_super  /dev/sda1
tune2fs -c0 -i0 /dev/sda1
mkdir -p /mnt/gentoo_usb
mount /dev/sda1 /mnt/gentoo_usb

Copy the Live CD to Live USB

We just clone the items from the Gentoo Live USB and change the the bootloader from isolinux to extlinux.

cp -avR /mnt/gentoo_cd/* /mnt/gentoo_usb/
cd /mnt/gentoo_usb
mv isolinux extlinux
mv extlinux/isolinux.cfg extlinux/extlinux.conf
rm extlinux/{boot.cat,elilo.efi,isolinux.bin}
extlinux -i ./extlinux

Edit the config file extlinux/extlinux.conf as necessary.

Modifying or Updating the Image

The filesystem is stored in the squashfs image and is therefore not open for direct update. Below we will mount the image, copy the contents out, chroot into that environment and perform necessary actions.

mount -o loop -t squashfs /mnt/gentoo_usb/image.squashfs /mnt/squashfs
mkdir /tmp/gentoo_usb_image
cp -aR /mnt/gentoo_usb/* /tmp/gentoo_usb_image/
mount -t proc none /tmp/gentoo_usb_image/proc
mount -o bind /dev /tmp/gentoo_usb_image/dev
chroot /tmp/gentoo_usb_image /bin/bash

Now that we are in the new environment it can be modified in almost any possible way. Once finished then re-package the directory into a squashfs image.

cd /tmp
mksquashfs gentoo_usb_image image.squashfs
cp image.squashfs /mnt/gentoo_usb

Now it's ready to boot!

Modifying the initrd Image

Extract the image, edit stuff as necessary and then re-save and compress.

mkdir /mnt/gentoo.initrd
cd /mnt/gentoo.initrd
gzip -cd /mnt/gentoo_usb/extlinux/gentoo.igz | cpio -div

Now re-compress

cd /mnt/gentoo.initrd
ls | cpio -o |gzip > /mnt/gentoo_usb/extlinux/gentoo.igz

For the Really Lazy

For those of you who are too lazy to try the above steps, or don't care about how it works, you can use these images. We'll update these as newer versions of Gentoo are released. Simply download the tarball, extract onto a bootable partition on a USB device.

See Also

Change Log

Thanks / Shouts

Thanks to jamisnemo on #gentoo for encouraging us and validating the amd64 image.