HOWTO LiveUSB

From Gentoo Linux Wiki

Jump to: navigation, search
This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Creating a LiveUSB device from the latest LiveCD or LiveDVD is easy. Here we use extlinux as the boot loader.

Contents

[edit] Notational Conventions

  • The USB device is /dev/sda, its first partition is /dev/sda1 and we mount the first partition at /media/usb.
  • The ISO is stored at ~/that.iso and mounted at /media/live-iso.

[edit] Process

[edit] Format The Device

We first partition it into one big bucket of bytes, and then run mkfs.ext3 to format it. At this stage, we do two things to ensure the device is bootable -- use the a directive in fdisk, and put a Master Boot Record on the device.

Code: Preparing Media
  :01;  fdisk /dev/sda

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1015, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1015, default 1015): 
Using default value 1015

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

  :02;  mkfs.ext3 /dev/sda1
mke2fs 1.40.3 (05-Dec-2007)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
125952 inodes, 251712 blocks
12585 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
8 block groups
32768 blocks per group, 32768 fragments per group
15744 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

  :03;  cat /usr/lib/syslinux/mbr.bin > /dev/sda

[edit] Copy The ISO

We use the -p with cp to preserve file permissions, and the -P option to ensure symlinks are never followed. The copy will take quite some time with the DVD.

Code: Copy
  :01;  mount -o loop -t iso9660 ~/that.iso /media/live-iso
  :02;  mount /dev/sda1 /media/usb
  :03;  cp -a /media/live-iso/* /media/usb

[edit] Add The Bootloader

Many other tutorials encourage you to use the FAT16 filesystem or one of its derivatives. For that filesystem, use syslinux; however, we are using ext3, so we need extlinux. The extlinux installer is called on the directory that contains the boot info -- in this case /media/usb/isolinux. It's okay to use the isolinux config file as is with extlinux.

Code: Bootloader
  :01;  pushd /media/usb
  :02;  mv isolinux extlinux
  :03;  mv extlinux/isolinux.cfg extlinux/extlinux.conf
  :04;  rm extlinux/isolinux.bin
  :05;  popd
  :06;  extlinux -i /media/usb/extlinux 

[edit] Unmount Everything

Once you are done, unmount everything and pull out the USB device. With your bootable Gentoo LiveUSB, you can boot UMPCs for great justice!

Code: Unmount It All
  :01;  umount /media/usb
  :02;  umount /media/live-iso

[edit] Tools

These less common packages have appeared in this HOWTO:

Personal tools