Tuesday, February 19, 2008

Linux on a stick part 2: Ubuntu 7.10

After some thinking and further reading on the net, I finally figured out a fairly simple way create a bootable Ubuntu 7.10 LiveUSB stick. And all under Linux. Here are the simple details I came up with to set up and configure a very minimal Ubuntu 7.10 Live USB thumb drive.
  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're using the downloaded ISO, open a terminal window and mount the ISO:
    sudo mount -t iso9660 -o loop /[location-of-iso]/ubuntu-7.10-desktop-i386.iso /mnt/iso
  2. Insert a USB thumb drive into a conveniently empty USB port on your computer running Linux. It should automatically mount. I'm going to use the same Cruzer Micro I used for Linux Mint 4. It really doesn't matter if it's clean or not, but for this experiment I did remove Linux Mint. You just need about 800MB of free space. USB drives are mounted under /media, and can be named /media/disk or /media/[volume-name]. For this example I've given my thumb drive the volume name LINUX, so it would be automatically mounted under /media/LINUX.
  3. Now copy the following files from the Ubuntu media. This works for either the mounted ISO or the CD-ROM. If you've got the CD-ROM mounted you'd copy from /media/cdrom. If you mounted the ISO you'd copy from /mnt/iso. Regardless the mount point the file system under either is identical:
    cp -R [mount-point]/.disk /media/[name-of-usb-drive]
    cp -R [mount-point]/casper /media/[name-of-usb-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. Add the following syslinux configuration text file (named syslinux.cfg) to the root of the USB thumb drive. It will contain the following two lines of text:
    DEFAULT /casper/vmlinuz
    APPEND boot=casper initrd=/casper/initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
  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. You can easily find it by typing the following in a terminal: mount | grep media. On my system it returned 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 left-clicking on the thumb drive icon on the desktop and selecting unmount. In a terminal window type 'sudo syslinux /dev/[device]' 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. 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 :)

Background

Some of the information, particularly the syslinux.cfg contents, came from CustomizeUbuntuLive. The directions actually call for fewer files, but I discovered through trial and error that for 7.10 you need a few more than what was originally called for.

There is also a link to a page on the openSUSE wiki that shows how to create a bootable openSUSE 10.3 on a thumb drive from a running openSUSE system. If I hadn't been so idiotic as to completely remove my original openSUSE 10.3 installation and replace it with Ubuntu 7.10 I could test this. The directions are far more elaborate but the results are actually closer to a fully usable Linux system on a thumb drive. Well, there's always openSUSE 11...

Update

Just for grins and giggles I mounted the Hardy Herron (8.04) Alpha 4 ISO, copied over the same files, and then booted it up again. The test system (the Gateway M680) came up with visual effects enabled. All in all it was a cleaner method for testing Ubuntu without having to burn one test coaster after another. After all, those alpha and then beta CDs wind up going in the trash and some landfill here in Florida.