Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


March 20, 2008

Create a Live CD that Runs in Persistent Mode on a Bootable USB Drive

It holds your tools and lets you save changes too
RSS
View this exclusive article with VIP access -- click here to join | See More Security Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

 Executive Summary:
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.

A portable toolbox on a USB drive is a handy thing—it lets you use your tools at any computer without having to install programs on the host computer’s hard drive. Last month, we explored how to create this bootable USB drive and showed you the quick steps for booting off a “live” Linux distro from a USB drive. (See "Create a Live CD on a Bootable USB Flash Drive" at http://www.securityprovip.com/Articles/ArticleID/97928/97928.html.) However, the system wasn’t persistent, which means that any changes you made to your toolbox would be gone at the next reboot. To customize your environment or install your own custom applications, you need an installation that’s persistent. To that end, let’s now walk through how to create a USB-bootable persistent configuration of a Linux installation using Ubuntu 7.10 Desktop Edition. Linux distributions vary in the tools that come installed, so if you choose to use a distro other than Ubuntu, you’ll need to search the Internet for instructions relating to that distro.

Getting Started
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

sudo qtparted

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

mount

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:

DEFAULT usbboot
append file=preseed/ubuntu.seed boot=
casper initrd=initrd.gz quiet splash --
LABEL usbboot
menu label Start Ubuntu Persistent
kernel vmlinuz
append file=preseed/ubuntu.seed boot=
casper persistent initrd=
initrd.gz quiet splash --
PROMPT 0

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.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Microsoft Misses Windows Mobile Sales Target

The warning signs were there. After boldly proclaiming that it would sell "more than" 20 million licenses to its Windows Mobile operating system by the end of its fiscal year on June 30, Microsoft later scaled that prediction back to "nearly" 20 million ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

Microsoft: Midori is Not a Future Windows

As I've written previously here and mentioned in the "Windows Weekly" podcast, the oft-hyped-of-late "Midori" project that Microsoft is currently working on is not designed as an update to its current family of Windows operating systems. Midori has been ...


Related Articles 7 Months with Ubuntu

Using a USB Flash Drive to Recover Windows Vista

How can I create a bootable USB flash device running Windows Preinstallation Environment (PE) 2.0?

Performing Forensic Analyses, Part 1

Security Whitepapers Anti-Virus Is Dead: The Advent of the Graylist Approach to Computer Protection

Getting the Job Done: Comparing Approaches for Desktop Software Lockdown

Instant Messaging, VoIP, P2P, and games in the workplace: How to take back control

Related Events Check out our list of Free Email Newsletters!

Security eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

Related Security Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

WinConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

Deploying SharePoint! In-Person Event Series – 8 Cities
Discover best practices and tips for deploying the perfect SharePoint infrastructure. Early Bird Price of $99 through Aug 29th.

Find a new job now on the all new IT Job Hound!
Search jobs, post your resume, and set up job e-mail alerts!

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Top Tools for Virtualization Disaster Recovery & Replication
View this web seminar on August 14th to learn about two tools that will result in faster backup and restore with P2V disaster recovery.

SharePointConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

VMworld 2008 - Sign Up Today!
Join your peers on September 15-18 at The Venetian Hotel in Las Vegas as VMware hosts VMworld 2008, the leading Virtualization event.



Microsoft® Tech•Ed EMEA 2008 IT Professionals
Advance your thinking with new ideas and practical real-world solutions at Microsoft’s FIVE day technical infrastructure conference 3-7 Nov., 2008. Register before 26 September 2008 to save €300.

What’s up with your network? Find out with ipMonitor
Availability monitoring for servers, applications and networks – FREE trial

Agent-less Remote Backup Service, Free 30 Day Trial
Award winning remote backup service at a competitive price with no min GB/month. Sign up Now!

Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.

Are You Really Compliant with Software Regulations?
View this web seminar that will help you with compliance best practices and check out a management solution to assure that you won’t be in jeopardy of an audit.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound
IT Library Technical Resources Directory Connected Home Windows Excavator SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing