Wednesday, February 20, 2008

Linux on a stick part 3: Ubuntu 7.10 'simplified'

Silly me. After reading about syslinux it suddenly dawned on me I was still making it too hard to transfer Ubuntu 7.10 LiveCD from CD to thumb drive. The key difference is copying all the files in the isolinux directory on the Ubuntu LiveCD to the root of the thumb drive, and renaming isolinux.cfg to syslinux.cfg. So here are simpler instructions for creating a bootable Ubuntu Live Thumb Drive under Linux.
  1. If you don't have an Ubuntu 7.10 Desktop LiveCD handy then download the ISO. If you do have it handy (you installed from the CD-ROM) then just drop it in the CD/DVD drive on your computer. If you've downloaded the ISO then open a terminal window and mount the ISO:

    sudo mount -t iso9660 -o loop /[location-of-iso]/ubuntu-7.10-desktop-i386.iso /mnt

  2. Insert a USB thumb drive into a conveniently empty USB port on your Linux computer. It should automatically mount. I'm going to use the same Cruzer Micro I used for Linux Mint 4. For this experiment I removed Linux Mint. USB drives are mounted under /media, and can be named /media/disk or /media/[volume-name]. For this example the thumb drive's volume name is LINUX, so it automatically mounts under /media/LINUX.

  3. Copy the following files from the Ubuntu media to the thumb drive. This works for either the mounted ISO or the CD-ROM. If you've got the CD-ROM mounted you'll copy from /media/cdrom. If you've mounted the ISO you'll copy from /mnt. Regardless the mount point the file system under either is identical:

    cp -R [mount-point]/.disk /media/[usb-volume-name]
    cp -R [mount-point]/casper /media/[usb-volume-name]
    cp [mount-point]/isolinux/* /media/[usb-volume-name]

    The last copy copies the files from the isolunux directory to the root of the thumb drive.

  4. We're going to use syslinux to add a boot loader to the USB thumb drive. It's doubtful you would have installed syslinux by default. If the syslinux package isn't installed and you're doing this from Ubuntu (or an Ubuntu-based distro) then use synaptic or apt-get to install it. You'll also wind up installing mtools (a dependency) along with syslinux.

  5. Rename isolinux.cfg (now in the root of the thumb drive) to syslinux.cfg.

  6. Use syslinux to install a boot loader onto the USB thumb drive. To do this you're going to have to unmount the USB drive. Before you do this find out what the USB device name is. This is different from the mount name, and you need the device name for installing syslinux. Open a terminal and type the following: mount | grep media. On my system it returns the following:

    /dev/sdb1 on /media/LINUX type vfat ...

    where the (...) are additional configuration flags and information. You want the device name, which is the first item (/dev/sdb1) on the line. I know this is my thumb drive because I gave it the volume name LINUX. Once you have that information unmount the USB thumb drive by typing 'sudo umount /media/[usb-volume-name]' in the same terminal window. Again in the same terminal window type 'sudo syslinux /dev/[usb-device-name]' and it will modify the boot sector of the USB thumb drive and place the file LDLINUX.SYS in the thumb drive's root. At this point you're done.
Plug the thumb drive into a system that can boot from a thumb drive, reboot, and watch Ubuntu 7.10 boot into 'Live' mode, complete with technicolor boot menu. You can even install from it if you like. The creation of a bash script to automate this process is left as an exercise for the reader :)