Installing Debian from a USB Key
As some of you may remember, I have recently bought a new server and have been waiting for the internet to set up linux on it. Well, now I have the internet I have no excuses.
Seeing as it's intended to be a network file storage system, it has no need for trivial devices such as floppy or CD drives, so I didn't buy it any. Instead I decided I was going to install over my network, booting from a USB flash drive memory stick key whateveryoucallit thinger.
I'm installing Debian stable 3.1 (sarge) on an i386 (Athlon Sempron). While the Debian documentation for installing on USB is helpful, the site structure is a total mess and I found it quite tricky to find everything that I needed. It also didn't help me solve the problems I faced, so I am writing this here in the hope that I can help somebody else doing the same thing as me in the future. That and so that when I try to do this again in the future and it all goes wrong, I can come back and check what happened.
The main page in the debian documentation is "4.4.1. Copying the files the easy way", but to do that you will need two files. The first is boot.img.gz, which is available from the hd-media directory of Debian-Installer, and the second is your installation ISO. Because my USB key is 256mb, I went with a network installation, and grabbed the 180mb netinst file from here, although there is a 40mb business card size if you have a smaller drive.
Although it is might be possible to set up a linux-booting USB key from within windows, I didn't bother looking because I already had a working linux machine. I had to recompile my kernel to be able to access my USB key - I added SCSI support, USB support, USB UHCI/OHCI support and USB Mass Storage, as well as support for FAT16, which was 'msdos'. Once rebooted, I had to:
modprobe usb-uhci
modprobe usb-storage
and then the drive was available at /dev/sda.
The next thing I did was follow the instructions in 4.4.1, but I ran into problems when I got the USB key to my server - it gave the ever-helpful message 'Boot failed'. It was not saying boot device not found though, so I knew the problem was with the USB key. Taking it back to the server and repeating 4.4.1 resulted in many error messages saying 'sense key medium error' and 'peripheral device write fault'. After a bit of playing, I used fdisk to wipe the partition tables, removed the drive and reinserted it, which seemed to fix it. So, I'd advise the following before doing 4.4.1:
fdisk /dev/sda
Check partition tables (p)
Delete all partitions (d then 1-4, repeat until p is empty)
Write the partition table and exit fdisk (w)
Remove the USB key and reinsert it.
Now I followed the instructions in 4.4.1 again without any problems:
zcat boot.img.gz > /dev/sda
mount -t msdos /dev/sda /mnt
cp debian-31r0a-i386-netinst.iso /mnt/deb31r0a.iso
umount /mnt
This time when I took it to the server it booted up successfully and asked me several questions. However, when it tried to locate the ISO it failed. After a little prodding I decided that it wasn't looking at the USB key, so of course it was failing to find the ISO there. However, once the install wrapper has failed to find the ISO it offers access to a shell, so I did the following:
Select the menu option to execute shell
lsmod
reveals no usb-ohci. My guess is it only looks at usb-uhci, or forgets to look at usb-uhci and usb-ohci at all. So:
insmod usb-ohci
hw-detect
Now the USB key has been found, so we can:
mount /dev/scsi/host0/bus0/target0/lun0/disc /cdrom
Then just ctrl+d to return to install menu, and select the option to scan hard drives again. Hey presto, it all works.
No doubt I will run into more problems as I continue installing, but it all seems to be working fine now, making my biggest problem finding an obscure southpark reference as the name for my machine...
Leave a comment
- Add a comment - it's quick, easy and anonymous