Sunday, August 8, 2010

Setting up a Debian install USB stick from Windows


I know, I am a dinosaur. I am still stuck with Debian when everybody has switched to Ubuntu. What can I say? I just like the way it installs. I have complete control over what goes on and not. My favorite is to install the base system and pick and choose the rest for myself.

The way I used to do it ... 1) floppy disk (yes, I still do that) or 2) netinst CD. Then you do the usual and hook up the network, and everything else installs like a charm. Now floppy disk are so legacy no one wants to have anything to do with them, but I am still very much into netinsts. Downloading all the DVDs just takes way too much time, and I am not very patient.

Here is the problem. A lot of new(er) laptops and netbooks don't come with an internal CD or DVD reader/writer anymore. And at this age, if you want to install something, you can just mount the iso or dmg or just unzip the archive. So for me this doesn't justify carrying an external CD-ROM. So I started looking for ways to run my Debian netinst with a USB stick.

Here is another problem. I only have a Windows machine (read my post on my Gigabyte M912). You read instructions on making a netinst USB stick and you will quickly realize they assume that you are doing this from a linux box. There isn't much consolidated information on doing this from Windows, as if they don't want you to do it from Windows. Why, is it because people think it is too easy?

But while we contemplate on this, I need to get a netinst USB stick pronto.
This seemingly easy procedure took me over a week to figure out, but here it is.

What you need

1. A USB stick with at least 512 Mb of storage. It's not hard to find one these days.

2. A utility called Syslinux. You can download it here. Pick the .zip file with the highest version.

3. A machine that runs Windows (I used XP, but I am sure Vista and 7 will do just fine).

I am also assuming that you know your way around the command prompt in Windows. Here is a basic tutorial you can refer to if you don't know anything, or if you need a refresher. I assure you it's not hard to learn. Just be careful when you are erasing something. There is no recycling bin to store erased items in the command prompt so they are effectively gone.

What you do

1. Fire up the Command prompt, make a directory (folder) in a very convenient spot for your command prompt. For example, c:\bootusb. (and I will be using that throughout). You don't have to do that, but it keeps everything nicely organized. Putting it in c:\ also makes it easier to access from the command prompt.

2. Unzip the contents of the Syslinux .zip file in something like c:\bootusb\syslinux. Preserve the directory structure.

3. Download the USB installer from Debian. I choose squeeze (testing) ... you can find the files here. The files that you should pick up ... boot.img.gz, initrd.gz, and vmlinuz. Don't worry about the subdirectories.

4. Now pickup the netinst image here. Pick up the one that ends with "-netinst.iso". It should be about 200 Mb, so it may take some time if you have a slow connection.

5. Keep these files in a single directory (e.g., c:\bootusb\system). We will need them later.

6. Now, format your USB stick. If the stick has a low capacity (e.g., 512 Mb), you can use the FAT16 file system. Otherwise, use the FAT32 file system. Make sure you backed up anything you need from the stick before formatting.

In the next steps we are going to use Syslinux to make your usb stick bootable, and then copy the installation files.

1. Go the the command prompt, and go to the directory containing Syslinux (e.g., c:\bootusb\syslinux). Go to the win32 directory.

2. Assuming that your USB stick is in the F: drive, type the following command: syslinux -ma f:. This installs the bootloader in the USB stick.

3. Copy all the netinst system files (i.e., all the files from the c:\bootusb\system directory) to the root directory of the USB stick.

4. On the root directory of the USB stick, create a file called syslinux.cfg. This file will give you the boot options, and tells the computer what file to boot up. Copy and paste the code below:

DEFAULT linux
Label linux
Boot Installation
KERNEL vmlinuz
APPEND ro root=/dev/sda1 initrd=initrd.gz

Now you should have a netinst USB stick for my (and perhaps your) favorite operating system. I think this will also work with other Linux distributions, so I encourage you to try them out.

To test your system, set up the BIOS of your computer so that the USB stick is first in the boot order. Save the BIOS settings and watch it run. Just don't do the actual installation, though.

No comments:

Post a Comment