Monday, July 26, 2010

Using the Boot Image in Ubuntu

The boot.img.gz image is a self-contained file system and only uses 8 MB of disk space. If you have a bigger thumb drive (for example, 64 MB or 2 GB), then you can copy diagnostic tools or other stuff onto the drive.

In order to create a bootable USB drive, you will need a boot loader. The choices are GRUB or SYSLINUX. There are significant tradeoffs here. GRUB is the default boot loader used when Ubuntu is installed. However, using GRUB requires you to know the drive identifier, such as /dev/sda1.

Since you may plug in and remove USB devices, the identifier may change, breaking the boot loader’s configuration. SYSLINUX does not use a static drive identifier, but is limited to supporting FAT12 or FAT16 drives. Since USB devices are expected to be portable, use SYSLINUX:

sudo apt-get install syslinux mtools

The main steps require you to format the drive as FAT16 and use syslinux to make it bootable.

1. Start a shell with root privileges:

sudo bash

2. Unmount the USB drive, if it is already mounted.

3. Format the drive as a FAT16 USB floppy drive (in this example, /dev/sdc) and mount it:

mkdosfs -I -F 16 /dev/sdc
sync
mkdir /mnt/usb
mount -o loop /dev/sdc /mnt/usb

4. Mount the boot.img file. You will use this to provide the boot files.

zcat boot.img.gz > boot.img
mkdir /mnt/img
mount -o loop boot.img /mnt/img

5. Copy the files over to the USB drive. This can take a few minutes.

sudo bash # become root, run these commands as root
(cd /mnt/img; tar -cf—*) | (cd /mnt/usb; tar -xvf -)
sync

6. Set up the files for a bootable disk. This is done by copying over the SYSLINUX configuration files for an ISO image (isolinux.cfg) to a configuration file for a FAT16 system (syslinux.cfg):

mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg
rm /mnt/usb/isolinux.bin
sync

7. Unmount the drive and make it bootable by installing the boot loader:

umount /mnt/usb
syslinux /dev/sdc
sync
eject /dev/sdc
exit # leave the root shell

Now you can boot from the USB drive in order to install the operating system.

Source of Information : Wiley Ubuntu Powerful Hacks And Customizations

No comments: