Installing Debian from a USB Key
I’m astonished how quickly CDs and DVDs are going the way of the Fondue Fork. Seems that everyone is downloading stuff these days and USB devices have exceeded DVDs in capacity already.
I can see it won’t be long before DVD drives will be an optional extra on new PCs (especially laptops) and will eventually disappear like floppy drives (remember them ?).
So it’s time to look at installing from USB on a machine which has no disc drive at all. I’ve found a few guides out there on the internet but none of them were easy to follow. I had to read several of them and then I still had to guess at stuff that wasn’t mentioned.
So here is my guide which is a little more comprehensive.
NOTE 1: I am assuming your USB device is /dev/sdb. If yours is not, you will have to change the examples to suit.
NOTE 2: I’m assuming you are logged in as a regular user. if you are logged in as root, just drop “sudo” off the beginning of all these commands.
Step 1 - Download the installation image
While there are several “small” installs for putting on a credit-card CD and so on, USB sticks are now large enough that you can use a normal install CD image. I am going to use the Debian Net Install which weighs in at around 160MB. This should easily fit on a 256MB device which quite frankly, people throw away these days because it is so uncool to have such a small device dangling from your keyring.
Go to http://www.debian.org/CD/netinst/ and download the netinst image for your platfom (if you don’t know, it’s probably i386).
Step 2 - Partition and Format the USB device
Most USB keys come pre-formatted with a FAT16 or FAT32 file system. If this is the case with your stick, just erase all the files on it and proceed to Step 3.
But of course, I had previously formatted mine with EXT3 so I’ll need to reformat it with a DOS format.
First set the partition type to DOS
sudo sfdisk -c /dev/sdb 1 c
Next, format the partition.
sudo mkdosfs /dev/sdb1
Step 3 - Obtain a kernel and RAMdisk image
Next you need an hd-install kernel and initrd image. You can download these from Debian also. For the current version of the kernel, they should be available from here:
http://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/
Grab the two files vmlinuz and initrd.gz then mount your USB device and copy them onto it:
sudo mount /dev/sdb1 /mnt sudo cp vmlinuz /mnt/ sudo cp initrd.gz /mnt/
Then you will need to make a file on the USB device called syslinux.cfg - just create a plain text file. Cut and paste the following two lines into it:
default vmlinuz append initrd=initrd.gz
Step 4 - Copy the installation image
Next copy the ISO file you downloaded onto the USB device. From the commandline you can do it like this:
sudo cp debian-40r3-i386-netinst.iso /mnt/
Step 5 - Make the device bootable
You will need to have a couple of additional packages installed to do this:
sudo apt-get install syslinux mtools
Type these commands to make the stick bootable:
sudo syslinux /dev/sdb1 sudo install-mbr -r -p 1 /dev/sdb
Now you can unmount the USB device and you are good to go!
sudo umount /mnt/usb
UPDATE - I corrected an error in this, if you tried following it before 15-Jul-2008, you might have ended up with a non-working installer.
