Wednesday, March 4, 2009

Booting CentOS from a Thumb Drive

The high capacity and low cost of portable flash devices allows a complete Linux server or development environment to be carried in your pocket. Plugged into a computer than can boot from portable USB devices, a CentOS thumb drive provides an unmatched capability to take your work (or fun) wherever you go.

First, you must buy a suitable thumb drive. Although a 4GB drive is sufficient in most cases, I recommend an 8GB drive to provide plenty of space for data storage. The fastest 8GB flash devices I've come across are the Corsair Voyager GT drives. Besides being fast, they come wrapped in a thick rubber coating which provides an extra layer of protection. You'll also need the CentOS install DVD. I used CentOS 5.2.

Because a careless error could overwrite your hard drive, I recommend you back your vital data up to another computer or removable media before beginning.

Insert the CentOS DVD into the DVD reader and the thumb drive into a USB port. Start the computer, using BIOS setup, if necessary, to tell the computer to boot from the install DVD. Once the computer boots from the DVD, begin the installation process.

Although generally you can treat the thumb drive install exactly the same as installing to a hard drive, there are a couple of tricky corners you need to navigate to ensure you don't mess up the boot loader on your computer's hard drive. First, make sure that you select the "Create Custom Layout" when the disk format & partition page appears. If you use the default setting, the boot loader of your hard drive will be overwritten.

Although different configurations are possible, I recommend a /boot partion of 100MB, a swap partition of 1024MB (1GB), with the rest of the drive allocated to root (/). When creating your disk layout, make sure that you're modifying the correct device - you don't want to overwrite your hard drive. The next step is to make sure that the boot loader is loaded into the Master Boot Record (MBR) of the flash device, NOT the hard drive. To do this, select the Configure Advanced Boot Loader Options and change the drive order so that the flash device is at the top and the box is checked.

Configure your package configuration as desired and let the install proceed. Once the installation is complete, remove the DVD and reboot from the thumb drive, using the BIOS setup, if necessary, to boot from the correct device. Upon first boot, various configuration items must be completed. After the initial boot, however, subsequent boots should be smooth and require only a login. Of course, if you use multiple computers with your new CentOS flash drive, you may have different experiences with screen resolution and network connectivity.