Debian netboot/net install from a USB Drive

Today I ran into an interesting problem. On my desk sits a brand new server which was configured and built for speed. I was all ready to pop in my Debian GNU/Linux DVD when I noticed it was missing a CD/DVD drive! I quickly searched for some options and chose to try the network install using a local area network TFTP server. This soon proved to be a problem as the BIOS on the server did not have an option for a network boot using that PXE whatever :) .

The solution: a simple and easy boot-able USB drive!

The first thing to do is insert your USB drive into a laptop already running Debian. If you’re running a desktop like Gnome be sure to unmount the USB drive if it was automatically mounted. Now open up a terminal and su to root access. Your going to need a couple of packages: mbr and syslinux. If you do not already have them do a quick:

# apt-get install mbr syslinux

The next thing to do is find which device file is mapped to your USB drive. You simply execute dmesg and scroll up a bit untill you see information on your USB drive. The easiest way I’ve found to do this is by the following:

# dmesg | grep sd

This command pipes the output to grep so that we may search for “sd”. You should see something like the following:

[79316.428044] sd 4:0:0:0: [sdb] 1994385 512-byte hardware sectors (1021 MB)
[79316.432683] sd 4:0:0:0: [sdb] Write Protect is off
[79316.432683] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00
[79316.432683] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[79316.432683]  sdb: sdb1
[79316.436328] sd 4:0:0:0: [sdb] Attached SCSI removable disk

You’ll quickly notice our USB drive is attached to /dev/sdb (your output could be something other than sdb). The other helpful hint is the line that says “sdb: sdb1″. Now that we know this, we can use the tools we just downloaded to get our USB drive ready by executing the following:

# install-mbr /dev/sdb
# syslinux /dev/sdb1

Now we’re ready to mount the USB drive. I typically use /mnt/usb as my mount point for USB drives, which you can do the same by creating the usb directory in /mnt and then mounting the drive:

# mkdir /mnt/usb
# mount /dev/sdb1 /mnt/usb

Now that your USB drive is all ready to go, we should grab the Debian Linux files that are necessary. We’re going to download the stable version of Debian amd64 and save them into /mnt/usb or whereever you mounted your USB drive. You can retrieve these files using a web browser or wget:

Now that you have mini.iso, initrd.gz, and linux saved on your USB drive, you need to create one mroe file. This file is called syslinux.cfg. You can use a text editor, a command line editor like nano, or just simply run the following command:

# echo -e "default linux\nappend priority=low vga=normal initrd=initrd.gz ramdisk_size=12000 root=/dev/ram rw" > /mnt/usb/syslinux.cfg

Unmount your USB like so:

# umount /dev/sdb1

Your USB is now ready to install Debian!

The very last thing I want to share, is after booting up my new server with the USB drive inserted, I received a prompt like the following (which I have no idea what it is):


To get past this hit the A key. The prompt then changes to the following:

MBR 1234F:

I *think* this prompt is giving you the options 1, 2, 3, 4, or F. To install Debian I hit the 1 key and away I went…
Update: Thanks to a reader this is no longer a mistery :) . Please read WofFS’s comment below. Thanks WofFS!

EDIT: Do yourself a favor and remove the USB drive once the installer is running. I left mine in and GRUB wrote itself to the master boot record of my USB instead of the hard drive.

One Response to “Debian netboot/net install from a USB Drive”

  1. WofFS says:

    from /usr/share/doc/mbr/README:

    The boot prompt looks something like this:


    This is the list of valid keys which may be pressed. This means that
    partitions 1, and 4 can be booted, also the first floppy drive
    (F). The ‘A’ means that ‘advanced’ mode may be entered, in which any
    partition may be booted. The prompt for this mode looks like this:


    The only other valid key which may be pressed is RETURN, which
    continues booting with the default partition.

    from Manual page install-mbr(8):

    The list of valid partitions and the default partition can be config-
    ured through the -e and -p options to install-mbr.


Leave a Reply