|
Installing Debian Sarge
from a USB memory stick (USB key)
Maintained by Pascal Le Bail <[email protected]>.
I want to thank everyone who sent me hints and corrections to this page.
Many Debian boxes need their floppy and/or CD-ROM drives only for setting up the system and for rescue purposes. If you operate some servers, you will probably already have thought about omitting those drives and using an USB memory stick for installing and (when necessary) for recovering the system. This is also useful for small systems which have no room for unnecessary drives.
You can find the latest version of this document at http://d-i.pascal.at/.
Prerequisites
This document applies only to Debian Sarge on the i386 architecture. For a successful installation on such a system, you will need:
A mainboard with a USB connector
A BIOS capable of booting from a USB memory stick (the corresponding item on the BIOS setup screen is usually called "Boot from USB-ZIP" or sometimes "Boot from removable disk"). In some cases it might help to upgrade your BIOS.
A USB memory stick large enough to contain the necessary files (see below). To increase your chances, a stick which complies to USB 1.1 and not USB 2.0 is recommended, since there seem to be some BIOSes out there which cannot boot from USB 2.0 media.
If you want more than a minimal installation, you will also need access to those parts of Debian, which don't fit on the USB stick. In most cases, a network interface and a connection to a Debian mirror will be used. Of course, you can also use a Debian CD-ROM (set) or its image on any local drive instead.
Obtaining the files
The files required for booting from a USB stick can be found in the main/installer-i386/current/images directory of the Debian distribution. There you will find some subdirectories for different boot media. If you want to use the USB stick only for booting and then to fetch the packages of the base system over the network (from a Debian mirror), you should change to the netboot directory. If you want to install the base system from a Debian ISO image contained on the USB stick, then choose the hd-media directory.
Preparing the stick
For preparing the USB stick you will need a system where Linux is already running and where USB is supported. You should assure that the usb-storage kernel module is loaded (modprobe usb-storage) and try to find out which SCSI device the USB stick has been mapped to (in this example /dev/sda is used). To write to your stick, you will probably have to turn off its write protection switch.
In order to start the kernel after booting from the USB stick, we will put a boot loader on the stick. Although any boot loader (e.g. LILO) should work, it's convenient to use SYSLINUX, since it uses a FAT16 partition and can be reconfigured by just editing a text file. Any operating system which supports the FAT file system can be used to make changes to the configuration of the boot loader. Since most USB sticks come pre-configured with a single FAT16 partition, you probably won't have to repartition or reformat the stick. If you have to repartition it anyway, start cfdisk or any other partitioning tool and create a FAT16 partition.
Copying the files - the easy way
There is an all-in-one file which contains all the installer files (including the kernel) as well as SYSLINUX and its configuration file. It resides in the hd-media subdirectory of the Debian installer images directory and is called boot.img.gz. You only have to extract it to the FAT partition on your USB stick:
zcat boot.img.gz >/dev/sda1
Again, take care that you use the correct device name for your USB stick.
After that, mount the partition on your USB memory stick (mount /dev/sda1 /mnt) and copy a Debian netinst or businesscard ISO image to it (please note that the file name must end in .ISO).
Partitionless installation: Instead of /dev/sda1 you may also use /dev/sda as your target. This leaves your stick without a partition table so that it will contain only the file system. The advantage of this method is that you don't have to rely on the existing (and possibly buggy) master boot record (MBR) of your USB stick. But be aware that you won't be able to access your stick using some third-party operating systems.
Copying the files - the more flexible way
If you like more flexibility or just want to know what's going on, you should use the following method to put the files on your stick:
Unless you have already a FAT16 file system on your stick, use
mkdosfs /dev/sda1
to create one. Take care that you use the correct device name for your USB stick. The mkdosfs command is contained in the dosfstools Debian package.
To put SYSLINUX onto the partition, install the syslinux and mtools packages on your system, and type
syslinux /dev/sda1
Again, take care that you use the correct device name. The partition must not be mounted when starting SYSLINUX. This procedure writes a boot sector to the partition and creates the file ldlinux.sys which contains the boot loader code.
Note: Although the Debian syslinux package does not officially depend on mtools, it definitely needs mtools to write to the FAT file system.
Mount the USB memory stick (mount /dev/sda1 /mnt), choose a Debian installer subdirectory as explained above and copy the following files to the stick:
vmlinuz - the Debian installer kernel
initrd.gz - the initial ramdisk image
the SYSLINUX configuration file (see below)
optionally a Debian ISO image
If you want to rename the files, please note that SYSLINUX can only process DOS (8.3) file names.
The syslinux.cfg configuration file should contain the following two lines:
default vmlinuz
append initrd=initrd.gz ramdisk_size=10240 root=/dev/rd/0 devfs=mount,dall rw DEBCONF_PRIORITY=medium
The DEBCONF_PRIORITY=medium lets the installer ask some additional questions which might be useful, but you may of course leave this option out.
Now you may put any Debian ISO image (businesscard, netinst or even a full one) onto your stick (if it fits). The file name of such an image must end in ".iso". If you want to install over the network, you will of course skip this step.
Finally the directory listing of the USB stick could look somewhat like this:
drwxr-xr-x 2 root root 16384 Jan 1 1970 .
drwxr-xr-x 25 root root 4096 Aug 6 23:03 ..
-rwxr-xr-x 1 root root 2554051 Nov 10 14:15 initrd.gz
-r-xr-xr-x 1 root root 7828 Nov 10 14:15 ldlinux.sys
-rwxr-xr-x 1 root root 117735424 Nov 10 14:16 netinst.iso
-rwxr-xr-x 1 root root 140 Nov 10 14:16 syslinux.cfg
-rwxr-xr-x 1 root root 769886 Nov 10 14:16 vmlinuz
When you are done, unmount the USB memory stick (umount /mnt) and activate its write protection switch.
Booting
Now connect the USB stick to the target system, boot it, enter the BIOS setup program and change the boot device to USB-ZIP. If everything works, SYSLINUX will load the kernel and the initial ramdisk, and the Debian installer will start.
Troubleshooting
If your system refuses to boot from the USB stick, the stick may contain an invalid master boot record (MBR). To fix this, use the install-mbr command from the package "mbr" (thanks for this tip to Marco d'Itri). If your USB stick is mapped to /dev/sda, remove the write protection and type
install-mbr /dev/sda
Important: Don't use install-mbr if you did a partitionless installation as mentioned above.
Hardware list
The USB based installation has been reported to work on the following systems:
VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 128 MB USB 1.1 stick
VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 512 MB USB 2.0 stick
VIA EPIA 5000 mainboard, BIOS Version 1.09, 128 MB USB 1.1 stick
Laptop with AMIBIOS 08.00.09
Supermicro 5013C server, 512 MB USB 2.0 stick (but the kernel doesn't recognize the SATA disks)
Gigabyte GA-7VAXP mainboard, 128 MB HP USB-MP3 key plugged into hub of Happy Hacker USB keyboard
ASUS P4C800-E Deluxe mainboard, BIOS Rev. 1015, 64 MB Fujitsu Siemens Memorybird USB 1.1 stick
MSI K8T-Neo Mainboard (for AMD64) with via K8T800 chipset
--------------------------------------------------------------------------------
Additions
Andreas John ([email protected], http://www.net-lab.net/):
I report to make a USB Stick work on a K7VMM Mainboard. There are two things you should take care for:
This particular Board has an AMIBIOS V 1.21.12. The Feature Setup in BIOS-Setup allows you to To enable/disable USB at all but also to enable "USB Device Legacy Support" and support for a "ThumbDrive Suppor for DOS". You will need to enable this to make the stick boot. I guess that there are some BIOSes out, which have similar features, so Keep you eyes open!
Another hint I want to give is that with many BIOSes you may press F8 shortly after POST (Power On Self Test, this is what "beeps" several times if your hardware is corrupt) to get in some kind of boot-menu, which lets you choose your preferred boot drive. There you can see your USB Stick by name. Mine is of type "USB RMD-FDD". If you don't get it there something is wrong with your hardware. If you are able to choose the device, but it doesn't boot, there is probably something wrong with the boot loader. Please check twice if you /dev/sdX device holds all neccessary files: syslinux, initrd, vmlinuz. boot.img.gz I took had no kernel on it! So I copied initrd and vmlinuz from the netboot directory onto /dev/sdX.
Adrian Bader:
I have a MSI K8T-Neo Mainboard (for AMD64) with via K8T800 chipset and it works properly.
It is important to enable these three things: USB in general (which is usually the case), "boot from other devices" and "USB Legacy Support" for "all Devices". Then we can press F11 during the bootup, which pops up the table to select the prefered boot device. There we can select the USB Memory Stick.
--------------------------------------------------------------------------------
Please send comments, additions and corrections to Pascal Le Bail. Last updated: 2004-09-08 |
|