This is a quick reference-post that shows how to install GNU/Linux to a USB stick from within a GNU/Linux distribution.
Download the ISO or CD image.
[antony@ARCH arch-core]$ wget http://mirror.neotuli.net/arch/iso/2007.08/i686/Archlinux-i686-2007.08-2.core.iso -O ~/archlinux.iso
Plug in the USB stick.
[root@ARCH antony]# dmesg | tail
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Mode Sense: 23 00 00 00
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Assuming drive cache: write through
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] 3903488 512-byte hardware sectors (1999 MB)
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Write Protect is off
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Mode Sense: 23 00 00 00
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Assuming drive cache: write through
Oct 26 15:08:23 ARCH sdb: sdb1
Oct 26 15:08:23 ARCH sd 2:0:0:0: [sdb] Attached SCSI removable disk
Oct 26 15:08:23 ARCH sd 2:0:0:0: Attached scsi generic sg1 type 0
Note the location of the drive (sdb).
Partition the USB stick.
[root@ARCH antony]# fdisk /dev/sdb
Then type the commands:
p – print partition table (count number of partitions, let’s call that n)
d – delete partition (type that n times)
n – add a new partition
p – create a primary partition
1 – make the primary partition the first partition
enter – default (first cylinder)
+512M – 512 megabytes from the first cylinder
n – new partition (create a second one for your files)
p – primary partition
2 – make this partition the second one
enter – default setting
enter – until the last cylinder on the USB stick
t – change partition type
1 – select partition 1
6 – partition code 6 (FAT16)
t – change partition type
2 – select partition 2
c – partition code c (FAT32 which is compatible with most file systems)
a – toggle bootable flag
1 – select partition 1
w – write table to disk and exit
Create the filesystem.
[root@ARCH antony]# mkfs.vfat -F 16 -n linux /dev/sdb1
[root@ARCH antony]# mkfs.vfat -F 16 -n vfat /dev/sdb2
Mount the ISO to a temporary directory.
[root@ARCH antony]# mkdir /mnt/iso
[root@ARCH antony]# mount -o loop /home/antony/archlinux.iso /mnt/iso
Copy the ISO’s contents to the USB stick.
[root@ARCH antony]# mkdir /mnt/usb
[root@ARCH antony]# mount /dev/sdb1 /mnt/usb
[root@ARCH antony]# cp -ra /mnt/iso/* /mnt/usb
Copy isolinux kernel to the root directory of the USB stick.
[root@ARCH antony]# cd /mnt/usb/isolinux
[root@ARCH antony]# cp vmlinuz ../
[root@ARCH antony]# cp initrd.img ../
[root@ARCH antony]# cp boot.* ../
[root@ARCH antony]# cp isolinux.cfg ../syslinux.cfg
Install the bootloader
[root@ARCH antony]# install-mbr /dev/sdb OR lilo -M /dev/sdb
[root@ARCH antony]# syslinux -s /dev/sdb1
[root@ARCH antony]# umount /mnt/usb