Friday, July 23, 2010

Booting Ubuntu from a USB Drive

Beyond file sharing, USB drives can be used as bootable devices. If your computer supports booting from a USB drive, then this is a great option for developing a portable operating system, creating an emergency recovery disk, or installing the OS on other computers.

Although most systems today support USB drives, the ability to boot from a USB thumb drive is inconsistent. Even if you create a bootable USB drive, your BIOS may still prevent you from booting from it. It seems like every computer has a different way to change BIOS settings. Generally, you power on the computer and press a key before the operating system boots. The key may be F1, F2, F10, Del, Esc, or some other key or combination of keys. It all depends on your computer’s BIOS. When you get into the BIOS, there is usually a set of menus, including one for the boot order. If you can boot from a USB device, this is where you will set it. However, every computer is different, and you may need to have the USB drive plugged in when you power on before seeing any options for booting from it.



Different USB Devices
Even if your computer supports booting from a USB device, it may not support all of the different USB configurations. In general, thumb drives can be configured one of three ways:

Small USB floppy drives—Thumb drives configured as USB floppy devices (that is, no partitions) with a capacity of 256 MB or less are widely supported. If your computer cannot boot this configuration, then the chances of your computer booting any configuration is very slim.

Large USB floppy drives—These are USB floppy devices with capacities greater than 256 MB.My own tests used two different 1-GB thumb drives, a 2-GB SD Card, and a 250-GB USB hard drive.

USB hard drives—In my experience, this is the least-supported bootable configuration for older hardware. I only have one computer that was able to boot from a partitioned USB hard drive. However, every laptop I tested seems to support this configuration.

Changing between a USB hard drive and a USB floppy drive is as simple as formatting the base device or using fdisk and formatting a partition. However, converting a large USB floppy device into a small USB floppy device cannot be done directly.

1. Use dd to create a file that is as big as the drive you want to create. For example, to create a 32-MB USB drive, start with a 32-MB file:

dd if=/dev/zero of=usbfloppy.img bs=32M count=1

2. Treat this file as the base device. For example, you can format it and mount it.

mkfs usbfloppy.img
sudo mkdir /mnt/usb
sudo mount -o loop usbfloppy.img /mnt/usb

3. When you are all done configuring the USB floppy drive image, unmount it and copy it to the real USB device (for example, /dev/sda). This will make the real USB device appear to be a smaller USB floppy device.

sudo umount /mnt/usb
dd if=usbfloppy.img of=/dev/sda

Source of Information : Wiley Ubuntu Powerful Hacks And Customizations

No comments: