Wednesday 11 June 2008

Gentoo Linux Live USB key

From live CD image, to bootable USB key in only a few minutes! I didn't believe my friend when he told me how easy this is, and yet he was right!

Here's what I did, you may need to tweak it a bit for your setup (especially your usb device - it could be /dev/sd[a|b|c|...]. Firstly I used one 1Gb USB key / thumbdrive / flashdrive / whatever, because I use the live CD image. You could use the minimal CD image and use a smaller key. It appears to me as /dev/sdb.

Your PC might need to be capable of treating the USB filesystem as a CDROM, otherwise this may not work for you. Tell me about your success!

0. dd if=/dev/zero of=/dev/sdb bs=512 count=1

The reason I did this is because I had corrupted both the mbr and partition table of the usb key. fdisk simply told me "unable to seek on /dev/sdb" and wouldn't continue. Skip this step if you can fdisk ok.

1. fdisk -l; fdisk /dev/sdb; fdisk a partition!

I join these steps together, cause they're all related to creating the partition. Make one partition covering the entire device. Something like "n p 1 t 1 83 a 1 w" should do it. Note I made it bootable, and I'm not using FAT.

2. mkfs.ext2 -L liveUSB /dev/sdb

You'll notice I'm using ext2 here. Wait for the device to finish writing, then unplug and re-plug it, or mount it manually.

3. sudo mount -t iso9660 -o loop /home/iain/Desktop/livecd-i686-installer-2008.0_beta2.iso /mnt/tmp/

There are multiple ways to do this. This is the one I chose.

4. sudo rsync -avP /mnt/tmp/ /media/liveUSB

5. sudo grub-install --root-directory=/media/liveUSB --no-floppy /dev/sdb

6. reboot!


Remember to set your BIOS to boot from your USB drive. Now you have a live CD on a USB key. Much nicer than burning!

YMMV.

Edit: There are some more comprehensive and detailed howto's available with slightly different techniques:
http://www.gentoo.org/doc/en/liveusb.xml
http://gentoo-wiki.com/HOWTO_Gentoo_LiveCD_and_LiveUSB

3 comments:

Anonymous said...

on step 5, your saying sda when it should be sdb, and its --no-floppy not --nofloppy. You may not care much, but you r one of the top hits on google which is where users look for documentation. Please fix it up or take it down, or simply state that this is only "rough" and some things might be wrong. Feel free to delete this comment afterwards.

Anonymous said...

oops /dev/sda is right, but it is --no-floppy.

Iain said...

Thanks for the feedback. Of course I care! Great to see that I'm high up on Google!

I've edited the --no-floppy option. You were right the first time, it should be /dev/sdb (for me anyway). I added a note at the beginning that this varies.

 
Copyright 2009 Another Blog. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan