home » howto » make a linux usb key
Despite all the fantastic tools around, making a Linux USB key seems to be inconsistent. Modern hardware seems to be fairly good, but older hardware may need fat 16 or fat 32 or superfloppy format. The eee pc 701 for example seemed to need superfloppy format to work.
Try erasing the contents of your USB key, then skipping down to Install Unetbootin below. You could be lucky, and save yourself some fiddling about!
Open a terminal and type:
$ mount
This will list your current mounts, including your USB key (if mounted). Take a note of the mount point (e.g. "/media/disk") and type:
$ sudo umount /media/disk
Once you are confident that the drive is not mounted, you may proceed.
Find you USB key by typing:
$ sudo fdisk -l Disk /dev/sdc: 64 MB, 64487424 bytes 4 heads, 32 sectors/track, 984 cylinders Units = cylinders of 128 * 512 = 65536 bytes Disk identifier: 0x5187ef1e Device Boot Start End Blocks Id System /dev/sdc1 * 1 983 62896 6 FAT16
This will lose any data on this drive!!!
Ignore the number after the letter, so in the above example the device is /dev/sdc, not /dev/sdc1; the 1 is partition 1, but fdisk works on the whole drive, not just a single partition.
$ sudo fdisk /dev/sdX Command (m for help):
At this point, nothing has really happened, you can "q" to quit and nothing will have been touched.
Disk /dev/sdc: 64 MB, 64487424 bytes 4 heads, 32 sectors/track, 984 cylinders Units = cylinders of 128 * 512 = 65536 bytes Disk identifier: 0x5187ef1e Device Boot Start End Blocks Id System /dev/sdc1 1 984 62960 83 Linux
Up to this point, nothing has actually been changed; if you are happy with the changes you have made, then:
The final step is to create the fat filesystem:
Note that this time we DO quote the partition number
$ sudo mkfs.vfat -F 32 /dev/sdx1
This process ends by sync'ing the disk.
For most systems, this can be easily achieved by simply unplugging and replugging in the key, and taking option to Mount when prompted. Equally you can mount manually by typing:
Change "mountpoint" below for an appropriate name
$ sudo mkdir /mnt/mountpoint $ sudo mount /dev/sdx1 /mnt/mountpoint
$ sudo aptitude install unetbootin

Run Unetbootin from your menu, either select a distribution and version, or take the option to install an already downloaded disk image.
Next select the usb drive.
Given the tiny size of my USB key, I am using slitaz, which is a minimal distribution.
Have a look at the contents of the USB drive, in at least one test, unetbootin had only copied a single file across. Just run unetbooting again if that happens.
That's it, you should now be able to reboot onto the drive.
My first attempt was using FAT32, which did not work. Next I tried FAT16, which also did not work, then I tried EXT2, by change partition type to "83 Linux" and then typing the following command (replacing the "x" for your correct drive letter):
$ sudo mkfs.ext2 /dev/sdx1
This time the USB key was detected as USB-HDD and booted perfectly. It does seem that everyone's has different experiences, and there is an element of trial and error to get things working.
If you have a usb key over 512mb and are using FAT32, then you might try reducing the size of the partition to 512k, and create a second partition with the remaining space.
See Alternative Methods for other options.
I understand that the problem with USB booting, is that many BIOS's understand the superfloppy format - i.e. a formatted but unpartitioned drive. This is easy enough to create under Linux, simply delete the partitions in fdisk and format with:
mkdosfs -I /dev/sdx
or possibly on older hardware:
mkdosfs -v -F 16 -I /dev/sdx
The problem is that superfloppies will not be auto-mounted under Linux, with the result that Unetbootin cannot write to them. But you can mount superfloppies manually:
$ cd /media $ sudo mkdir sdx $ sudo mount /dev/sdx sdx
Then use unetbooting to write to /dev/sdx, and not forgetting to umount afterwards:
$ sudo sync $ sudo umount sdx
Some distributions offer their own USB key creation software, including Ubuntu 8.10+, PuppyLinux 4.10+, and Slitaz, to name but a few.
Also, it is possible to obtain disk images that can be written to a usb key directly, thus circumventing these problems. For example: