Archive for May, 2008

Installing Debian from a USB Flash Disk

Sunday, May 4th, 2008

It was time for a fresh install of Debian on my ThinkPad X31. After 3 years of filling it up with random programs and university related stuff I felt this was the easiest path to a nice clean, fast system. I was also at a point where I felt comfortable in totally obliterating my Windows partition (which I never used) which had been sitting there as a kind of security blanket.

Anyway, for those that don’t know, the X series of ThinkPads are the ultra-portable models and in most cases come with no optical drive (unless you have the docking station). Previously I had used a USB based DVD drive to install the OS’s on it, but that was currently in use on another system (and installing from a flash disk did seem like a slightly nicer solution).

Getting Started

All we really need to get going is a flash disk (anything from 256MB and up should do), a network connection and an existing Linux system. As I was using the netinst ISO (160MB) most of the OS will be downloaded over the network after the initial system has been installed. The other point to note is (because we are using the easy way), everything on the flash disk will be wiped so double check it and backup if necessary.

Getting the files

There are only two files that we need, both can be found from

  • debian-XXXX-i386-netinst.iso
    This can be found by clicking on your architecture type (i386 for most) in the Small CDs section (replace XXXX with the current version).
  • boot.img.gz
    This can be found by clicking on your architecture type in the Tiny CDs, floppy disks, USB sticks, etc section. You then need to navigate to the hd-media folder.

Setup the flash disk

So now we need to setup our flash disk (remember, EVERYTHING WILL BE WIPED!!). Insert the flash disk and determine its location. The easiest way to do this is to execute ls /dev/sd* before and after you insert the disk and check what drive appears, or alternatively, a few seconds after plugging in, execute dmesg | tail. For me it was /dev/sdb. Now we need to put the boot image on the disk, this is done by executing:

zcat boot.img.gz > /dev/sdb

(zcat is a nice little program that rolls gzip and cat into one)
Once that’s done, we need to copy the ISO over to the disk as well. You might need to mount the disk if it isn’t done for you automatically. This can be done by executing:

mkdir /mnt/sdb
mount /dev/sdb /mnt/sdb

and then

cp debian-40r3-i386-netinst.iso /mnt/sdb

(Make sure you adjust for your version, architecture and disk location)

Boot Away

We are now all set to do the install. Just plug in your flash disk before turning on, and select it as the boot device when booting up. Make sure you have your network cable plugged in so you can get more than a very basic system installed. You now also have a convenient rescue and recovery tool.