Monday, May 18, 2009

Stop Wasting CDs When Installing Linux

Since, I've run out of blank CDs, I needed to find a way to install Linux some other way. I can't even count how many CDs I've thrown away because each one becomes worthless 6-9 months later when a new version is released.

Fortunately, if your BIOS supports it (and most newer ones do), you can also boot from a USB thumb drive. Then install Linux from a second thumb drive containing an installation ISO image. The ISO image can also reside on the local hard drive, but since you might end up formatting the entire drive, it's easier to just put it on a second flash drive.

Before you begin, make sure that the thumb drive is formatted ext2 or ext3. vfat (the default for USB keys) may work, but an NTFS formatted key definately causes problems. Just reformat it as ext2 or ext3 to be safe.

For Mandriva, you need to get the boot image for the release that you're going to install. Go to a Mandriva FTP site, and browse to /i586/install/images or /x86_64/install/images depending on your CPU architecture. The USB boot image is called all.img. Save this file somewhere on your hard drive.

Creating the USB Boot Device
To create the boot device, you must copy the boot image to your usb drive, using the dd command, not the copy command. To do this, plug in the drive, but do not mount it. To check where the drive is attached you can do one of two things. The first option is to open up /var/log/messages and look at the output generated when you plugged in the key. This will tell you where the drive is attached. The other, easier way is to open up Mandrake Control Center->Local disks->Manage disk partitions and look at the tabs at the top of the page. The thumb drive will (usually) be the only unmounted drive, and will often be the only other drive listed on most desktop systems. In my case the drive device node is /dev/sdb.

Next, open a konsole as root, and change directories to the location you saved the all.img file. Enter this command: dd if=all.img of=/dev/sdb In some cases, you may need to include the partition number as well: dd if=all.img of=/dev/sdb1 Adjust as necessary for your particular situation.

If creating the boot drive from within MSWindows, you will need WinImage.

Once that is done, you can reboot with the flash drive installed. During the boot process, it is usually a good idea to go into the BIOS and make sure Boot From USB Device is enabled, and that the flash drive containing the boot image is selected as the first boot device. Setting this up varies by motherboard. Older systems can not boot from a USB device, and a BIOS upgrade may or may not be able to remedy this situation. My ASUS A8V did provide a BIOS upgrade that added this functionality. Your mileage may vary.

Once the install screen comes up, plug in your second flash drive, and select Install From Hard Disk. From there enter the location of the ISO file, and away you go!

I recommend installing the Mandriva Free dual arch ISO. Once that is done, log in as root, and run urpmi task-kde4. From there login to KDE, and then using Mandrake Control Center, install all the other programs that you need. This results in a very small, quick system, with a full KDE4 install, with a minimum of running services.

It's also a good idea to visit easy urpmi to get all your software sources setup correctly. Just follow the easy directions and you're set.

The next experiment will be to do this with a Ubuntu based distribution: eBox Platform. Hopefully I can use the same boot device.

A final note: Be sure that there is no information on the thumb drive that you want to save, as the dd command will destroy some existing data on the drive. You have been warned.