It holds your tools and lets you save changes too
|We create a bootable USB drive that’s persistent, so you can use it at different computers and save changes to the installation. Ingredients include the Linux installation, Ubuntu; a 1GB flash drive; our expertise; and your brains.|
First, download Ubuntu 7.10 Desktop Edition (http://www.ubuntu.com/getubuntu/download) and burn the ISO image file to a CD-ROM. Next, boot a computer using your newly created CD-ROM. It doesn’t matter what OS is installed on this host computer—the tools we need boot from the Ubuntu Live CD. The computer you use to install the USB drive OS needs to have an Internet connection and networking hardware that Ubuntu recognizes. You’ll also need a USB drive that’s at least 1GB, although I recommend larger if you choose to install many custom applications. At the first Ubuntu screen, select Start or install Ubuntu and wait for the Ubuntu desktop to load.
Now insert your USB drive into this computer. Ubuntu will automatically mount your USB drive when you insert it. Look for desktop icons indicating that one or more partitions have been mounted, right-click them, and select Unmount Volume.
We are using the application open-source program qtparted to partition the USB drive for the installation. Select Applications, Accessories and launch Terminal. In the terminal window, type
sudo aptitude install qtparted
to automatically download and install the new program. Next, type
to start the program.
In the Device/Disks window, you'll see your host computer hard drives and flash drives as devices (e.g., /dev/sda and /dev/sdb). Select your USB flash drive by clicking it. In the left pane titled Drive Info, be sure the description you see applies to your flash drive. If it doesn't, select a different disk. Repeat until you find your USB flash drive. Be careful not to accidentally select your host computer hard drive and erase it.
After you select your flash drive, look in the right pane to see the partitions that might already be configured for it. Right-click each partition, and select Delete. Click Device, Commit to actually perform the action.
Next, with the flash drive still selected, right-click the newly created free space and click Create to add a new partition. Configure it with the following parameters:
Create As: Primary Partition
Partition Type: fat32
Size: 750 MB
Next, create a second partition in the remaining space as follows:
Create As: Primary Partition
Partition Type: ext2
Size: whatever is remaining
Next, right-click the FAT32 partition and select Set Active to make that partition active. When you finish with the configuration, tell qtparted to actually make the changes by selecting Device, Commit.
Unmount your USB drive partitions and physically remove the drive and then reinsert it. Now the two partitions should automount as disk and disk-1. Disk should be the FAT32 boot-enabled partition—to double check this, right-click it, select Properties, and confirm it’s 750MB with a file system type of vfat.
The disk partition is where we store the Ubuntu boot files; to copy them to this partition, double-click disk to launch the Ubuntu File Browser. Open a second file browser window, double-click File System in the left pane, and select cdrom in the resulting right pane. Click View, Show Hidden Files to see all the files and folders on cdrom.
Select the casper, disctree, dists, install, pics, pool, preseed, programs, and .disk folders and drag them over to the disk window to start the copy. You’ll encounter two copy errors because FAT32 doesn’t support symlinks, but these are OK to ignore—just click Skip to continue when the error occurs.
Next, copy the files casper/vmlinuz and casper/initrd.gz to the top level (root) of disk. (Essentially, you’re copying these files twice to different locations.)
Now we need to configure the boot-up behavior of the USB drive. From the Ubuntu top menu, select Applications, Accessories and launch Terminal. Then run the command
You’ll see a list of all the file systems and where they’re mounted. Look for line items containing disk and disk-1 and note their corresponding device. For example, the mount output
/dev/sdb1 on /media/disk type vfat
(rw, nosuid, nodev, shortname=mixed, uid=999, utf8, umask=077, usefree)
/dev/sdb2 on /media/disk-1 type ext2 (rw, nosuid,nodev)
means that /dev/sdb1 corresponds to disk and /dev/sdb2 corresponds to disk-1. Your entries might be different. You’ll need to update the commands below to match your configuration.
First, change the label on the disk-1 partition using the program e2label:
sudo e2label /dev/sdb2 casper-rw
Next, install the Linux bootloader syslinux and lilo using Ubuntu’s included installer, aptitude. Because aptitude installs the latest Linux packages from online sources, you’ll need your host computer connected to the Internet for this step. To install syslinux and lilo, type
sudo aptitude install syslinux lilo -y
You can safely ignore the warning lilo presents and press Enter. (It’s OK, we just need the binaries for syslinux and lilo to run the commands below; remember that right now, we’re actually operating in a non-persistent Live Ubuntu environment.)
Next, run syslinux to configure on the partition disk (remember that our disk corresponds to /dev/sdb1) by typing the following command:
sudo syslinux -sf /dev/sdb1
Run lilo to configure the master boot record on the USB drive by using this command:
sudo lilo -M /dev/sdb
Last, we need to create our syslinux configuration file. From the Ubuntu top menu, open Applications, Accessories, Text Editor and type the following lines:
append file=preseed/ubuntu.seed boot=
casper initrd=initrd.gz quiet splash --
menu label Start Ubuntu Persistent
append file=preseed/ubuntu.seed boot=
casper persistent initrd=
initrd.gz quiet splash --
In Text Editor, Click Save to save the file, then name the file syslinux.cfg. Click Save in Folder, and select the drive disk.
Running Ubuntu in a Persistent Mode
Now that the configuration is complete, you can shut down the host computer and remove the bootable Ubuntu CD-ROM. Leave the USB drive installed and power up the host computer. Instruct your computer to boot from the USB device—often this can be done by pressing a vendor-specific key upon startup. You should launch into the syslinux boot prompt. Press Enter, and Ubuntu should begin to load.
You'll encounter peculiarities when running Ubuntu Live CD in a persistent mode compared to running it after a complete install. For example, your username will be ubuntu and it won't be configured with a password, so the system will boot with root privileges. If you save files to /home/ubuntu/Desktop (~/ubuntu), you’ll see that they persist between reboots. If you try to change the default blank password for the ubuntu account, the change will appear to succeed, only to revert to no password on the reboot. Any programs you install will persist, but some might behave strangely. For example, in Mozilla Firefox, my Web-surfing history persisted between reboots but my custom home page and bookmarks didn't. These are quibbles that can be solved—just be prepared for differences when running in this mode compared to running a full-blown Linux installation. If you would like to find alternate methods for installing Ubuntu on a USB drive, check out the Ubuntu Wiki for more information (https://wiki.ubuntu.com/LiveUsbPendrivePersistent).
Tolerate its oddities, and you’ll find persistent Ubuntu Live CD a useful platform that you can take with you. As with most things Linux, you’ll need to spend time learning and tweaking the default installation to perhaps find workarounds for the quirks mentioned above.