Gentoo install min on USB stick

Download minimal CD ISO from gentoo.org


dmesg | tail
parted /dev/sdX
dd if=gentoo_image.img of=/dev/sdX bs=4M

Longer method

Taken from gentoo-en.vfose.ru
Install syslinux

emerge syslinux

Find the USB drive

fdisk -l

Clear disk partition table and boot sector

dd if=/dev/zero of=/dev/sdf count=1024

Create a partition table with 512-byte sectors and a primary partition of type 83 (ext2) with fdisk and make it bootable

fdisk -b 512 /dev/sdf
n p 1 enter enter
t 83
a 1 
p
w
Device     Boot      Start        End      Blocks   Id  System
/dev/sdf1   *           1        1009      500433   83  Linux

Format the partition ext2 and tune it

mkfs.ext2 /dev/sdf1
tune2fs -i 0 /dev/sdf1

install the mbr

equery f sys-boot/syslinux | grep mbr

Note: the listing above is for gentoo only. If you are using ubuntu, the listing above can be ignored.

cat /usr/share/syslinux/mbr.bin > /dev/sdf

If cat command returns Permission Denied error try with:

dd if=/usr/share/syslinux/mbr.bin of=/dev/sdf

mount the usb flash drive and disk image. If the device folder doesn’t exist, please create them before conducting the following listing.

mount -t ext2 /dev/sdf1 /mnt/usb/
mount -t iso9660 -o loop,user /downloads/install-x86-minimal-2008.0.iso /mnt/cdrom

install the system files

cd /mnt/usb/
cp -r /mnt/cdrom/* /mnt/usb/
mv isolinux extlinux
mv extlinux/isolinux.cfg extlinux/extlinux.conf
rm extlinux/isolinux.bin
rsync -av extlinux 

install the bootloader

cd /tmp
extlinux -i /mnt/usb/extlinux
umount /mnt/usb 

Lastly ensure the changes are synced to the USB Stick before removing it:

sync