All it takes is a minor error in the Windows Registry or a virus infection, and your operating system can become unbootable. But with a properly configured USB flash drive on hand, you'll always have a compatible replacement no further away than your pocket or keychain. In addition, the flash drive can also provide a secure browser and virus scanner, and lets you take your favorite DVD burning and Office software with you wherever you may go.
All that's needed is a bootable USB Flash drive with at least 256 MB of storage capacity and a Windows Setup CD. Using the program Bart PE Builder (Freeware), you can install Windows XP on the flash drive, along with other software as needed (and as available space permits).
Bart Lagerweij's free utility, PE Builder, condenses the original setup data for Windows XP into a slender operating system that is ready to run from a CD or a USB flash drive. This compact, portable version of Windows includes all the important system tools for dealing with a PC emergency. You can even add other programs to this collection, such as the media writing tool Nero Burning ROM or an anti-spyware package such as Ad-Aware SE Personal, during the installation process.
2. Expanding The Role Of USB Flash Drives
Flash drives aren't always recognized during the PC boot process. The USB flash drive controller and the PC's BIOS must be properly introduced to one another. That said, nearly all flash drives and PC can be configured so that the PC can boot from the flash drive.
You Need This: XP On The USB Pen Drive
In most cases, any compatible USB flash drive makes a suitable target for Windows XP installation. But the following system requirements must also be met:
- A USB flash drive with at least 256 MB of storage is enough for the uses described in this article. Additional system tools or applications require more space. The upper bound limits for storage in this case is 2 GB - a byproduct of the tool's use of FAT16 for the local file system.
- Most new motherboards recognize USB flash drives as valid boot media. But conventional motherboards that are more than two years old aren't likely to boot from a USB flash drive. But in many cases, this omission can be remedied through a BIOS update for that board.
- 1.5 GB of unused disk space is the maximum needed for the tool to do its job, particularly if you want to pre-install Service Pack 2 and RAM disk capabilities. 190 MB of unused space is all that's needed to use PE Builder and the applications described in this article, however. Additional plug-ins will increase storage requirements, as will additional tools or software.
- 512 MB of USB flash drive storage space is needed only if boot-up works from a RAM disk. Otherwise, 256 MB is big enough.
- Access to a USB 2.0 port is not mandatory, though booting with a USB 1.1 port takes about five times longer.
- A Windows XP Setup CD works fine as a foundation for PE Builder to generate the USB flash drive's contents.
Formatting The USB Flash Drive
Disk Storage Format Tool: This program from HP can format any USB flash drive
Most BIOS versions accept a USB flash drive as a boot disk only if it uses the FAT (File Allocation Table) file system. Before you can install Windows on the USB flash drive, it must first be formatted.
Warning! Windows XP also provides a tool to format USB flash drives, but the results of that process are error-prone. In a worst case situation, it can even destroy the flash RAM in a USB flash drive.
Installation requires the use of HP's freeware tool HP USB Disk Storage Format Tool instead. Once installed, you can run the program through this sequence of menu choices: Start, All Programs, HP Company. Select the USB flash drive you wish to format from the Device entry, then select FAT as the target file system for that device. Click Start to launch this process. Once complete, you must then copied the Windows XP boot files to the USB flash drive - namely,
%systemdrive%\boot.ini, %systemdrive%\ntldr, and %systemdrive%:\ntdetect (if you know the drive ID where these files live, use that instead - it's normally C). To make Windows Explorer display these files (they're ordinarily hidden), choose Folder Options... from the Tools menu, then click the View tab in the Folder Options window. Finally, in the Advanced Setting pick list, click the radio button underneath Hidden Files and folders that reads "Show hidden files and folders." Finally uncheck the box next to "Hide protected operating systems (Recommended)," so you can select and copy these all-important Windows XP files to the flash drive. The USB flash drive is now ready to boot your system. Next, you learn how to instruct your PC to boot from a USB flash drive.3. Set The System's Boot Device Sequence
AMI-BIOS: For most versions, managing a PC's boot device sequence appears under the "Advanced BIOS Features" menu
If your PC has a relatively new motherboard, its BIOS will already include the functions necessary to support USB-attached boot media. If so, you need only make the right selections in that BIOS menu to boot from a USB flash drive. Older PCs, on the other hand, won't accept USB drives as valid boot devices. This means a BIOS update that supports USB boot options is necessary. You can find information about where to obtain such updates from your PC's (or motherboard's) user manual, on the driver CD included with the PC (or motherboard) or on the vendor's Website.
Normally, the hard disk precedes the USB flash drive (which falls under the heading of USB-HDD in most BIOS menus) in the boot order. If the hard disk contains a viable boot sector, the PC will start up automatically using the information it contains. Only when the hard disk suffers from a boot sector defect or an operating system can't be found will the PC boot from the USB flash drive instead.
Change this boot order. Plug the flash drive in, boot the computer and enter the BIOS setup utility. Normally, this means holding down the DEL or F2 key just as the computer powers up and begins the boot process. If you read the initial startup screen on your PC carefully, it will tell you exactly what you must do to access and alter your BIOS settings.
If your PC uses AMI-BIOS from American Megatrends, there are two possible ways to alter the boot device sequence. Each varies depending on the version of AMI-BIOS that's installed.
For the first variant, there is no menu entry named "Boot." Navigate to the sub-menu named "Advanced BIOS Features." Navigate to the item named "Boot Device Select... " and designate the USB flash drive as the first device in the "Boot Device Priority" list by selecting "1st" as its value. Then, hit the Esc key and set both the "Quick Boot" and "Full Screen LOGO Show" items to "Disabled" (this lets you see the BIOS messages during startup on the monitor). Exit the BIOS Setup utility using the "Save and Exit Setup" item in the main menu.
For the second variant, use the "Boot" menu to select the USB flash drive. It will show up under one of the following headings: "Hard Disk Drive", "Removable Device" or "Removable Storage Device. " Next, select the USB flash drive as "1st Drive" in the first position, then hit the Esc key. That device should appear in the menu named "Boot Device Priority" which might also show up as "Boot Sequence". Inside that menu, designate the USB flash drive as the "1st Boot Device", hit the Esc key and save all changes in the "Exit" menu by selecting "Exit and Save Changes".
The Phoenix BIOS that's so popular in notebook computers also lists the USB flash drive in its "Boot" menu (which might also appear as "Boot Device Priority"). In this case, the flash drive may show up as an entry in the "-HDD" or "-Removable Devices" sub-menu. Select the device class ("-Hard Drive" or "-HDD" for example) and use the F6 key to move the flash drive to the top of that list. Exit the BIOS Setup program by striking the F10 key, followed by the Enter key, to save all settings.
4. Test Your Settings
Whatever BIOS your PC may use, it's important to make sure all of its USB options are activated. These may include "USB Legacy Support" and "USB 2.0 Controller". Whenever possible, you should also extend the setting that governs the timeout period for how long the BIOS will wait for a response from the USB flash drive. Some of these devices take a half minute or more to respond to a boot-up instruction from the motherboard. Thus, if you see a BIOS option that reads something like "USB Mass Storage Reset Delay", set that value as high as it will go whenever boot-up problems should occur.
Many motherboards offer options to change the emulation type for certain devices, including USB flash drives. The default setting for "Emulation Type" is usually "Auto". If this causes problems, try other settings instead. First, try "Hard Disk", then try "Forced FDD", then try "Floppy" as your last option. For each new setting for emulation type, your computer must reboot for it to take effect. Also, you must reset the boot device sequence or priority in the BIOS each time as well.
Many older USB flash drives, especially those that belong to the first generation of USB 2.0 memory devices, have problems with data transfer between the flash drive controller and the BIOS. If boot-up won't work with the flash drive set to "High Speed Mode," try the slower "Full Speed Mode" option instead (if the BIOS offers that choice). This slows the data transfer rate from a maximum of 60 MB/s to less than 1.5 MB/s, which makes Windows boot up at a terribly leisurely pace. Your next step should be to make a BIOS update, so that the PC will also boot using the far faster "High Speed Mode."
5. Add Service Pack 2
The PE Builder program that installs Windows XP onto your USB flash drive requires an actual Windows XP CD. If you already have a Windows XP CD that integrates Service Pack 2, skip this section and jump ahead to the heading that reads "Adding Utilities".
Create a new folder on your hard disk (something like C:\sp2\winxp will do nicely). Use Windows Explorer to copy the entire contents of your Windows CD into that folder. To make sure that hidden files and system files are also copied, make sure that you've set Folder Options in Explorer to "Show hidden files and folders" and have unchecked the box next to "Hide protected operating system files (Recommended)" as described earlier in this article. Create a second folder named C:\sp2\sp2 for the update files as well.
Download The Service Pack
Installing Service Pack 2: The Setup Assistant activates all the Setup files from Windows XP
You'll either want to obtain the free Update-CD for Service Pack 2 or download the 256 MB file for this service pack from Microsoft.com/downloads . Download the version called "Windows XP Service Pack 2 for IT Professionals and Developers". If you want the download for a language other than English, select the language from the "Change Language" pull-down menu, then click "Download". Save this file (which shows up in Internet Explorer as "Windows XP-KB835935-SP2-ENU.exe") in a file named "xpsp2.exe" into the C:\sp2 folder. If you've got the SP2 CD, copy the file named "xpsp2.exe" into that folder instead.
Open a command window using the Start, Run menu entries, then type "cmd" into the Open: text box, and click the OK button. You can then extract the contents of the service pack by typing the following instruction at the command line:
C:\sp2\xpsp2.exe -u -x:c:\sp2\sp2
Updating The XP Setup Files
You can update all of the XP Setup files in the "C:\sp2\winxp" folder with the following command line instruction:
The Setup Assistant activates all of the updated XP Setup files, as part of which the file named "win51ip.SP2" appears in the "C:\sp2\winxp" folder. Double-click the file named "C:\sp2\winxp\README.HTM" to open that file in your default Web browser. This file should contain the statement that "This release of Windows Microsoft Windows XP includes Service Pack 2 (SP2)" (on versions of Windows XP that integrate SP 2, and on versions of Windows MCE 2005, this text appears when you click the hyperlink that reads "Important Information About This Version of Microsoft XP".
6. Adding Utilities
Windows XP normally requires more than 1 GB of storage space on a hard disk. To enable the operating system to fit on a 256 MB USB flash drive, all non-essential components must be stripped away. The freeware program PE Builder handles the selection of XP components in this case. It installs something called Bart PE, a much-reduced version of Windows XP that also includes system utilities.
PE-Builder-Setup: If possible, install PE Builder in a folder called "C:\Program Files\pebuilder313"
Install PE Builder. You'll find the program listed under "Computer, USB-Stick-Windows". Accept the default installation path - namely "C:\Program files\pebuilder313". The PE Builder program includes many useful system tools, which it writes to the USB flash drive along with Windows XP. These appear in the sub-folder named "C:\Program Files\plugin" - among which, for example, you'll find the file manager a43 inside a further subfolder named "\a43\files". The file named "a43.inf" contains data otherwise found in the Windows Registry. For some such subfolders in the plugin folder, you'll find the program files to be missing. These belong to third-party tools such as Ad-Aware or Nero Burning ROM that PE Builder doesn't install by default. But these subfolders do contain the necessary INF files that PE Builder can use should you decide to include these programs in what's written to the USB flash drive yourself. Here's how that works:
Nero Burning ROM
First, install the DVD burning program Nero on your PC. Next, copy all the files from the installation folder - usually this will be C:\Program Files\ahead\Nero" - into the PE Builder subfolder named "C:\Program Files\pebuilder313\ plugin\nero burning rom\files". Now, open the file named "penero.inf" with a text editor in the plug-in folder named "nero burning rom" and look for the area where the Nero version you've downloaded is identified: "5.x" or "6.x". Remote all semi-colons from the entry named "[Software.AddReg]" and delete all three numbers that follow as well. Replace those values with your user name, the company name and the serial number for your copy of the software. Save the file, then exit the text editor.
Ad-Aware SE Personal
Install the anti-spyware program Ad-Aware SE Personal (Freeware). You'll find it under the heading, "Computer, USB-Stick-Windows". Update the program. Copy the files named "defs.ref" and "ad-aware.exe" in the plug-in subfolder named "C:\Program Files\pebuilder313\plugin\adawarese\files".
The Drive-Snapshot imaging tool belongs to the standard collection of programs that PE Builder installs. This particular version is an evaluation copy that only works for a certain limited trial period. After the trial period elapses you can still restore drive images you've already captured, but it won't let you make any new snapshots thereafter. To make the tool work without such restrictions, you need a full version of the "snapshot.exe" file. You can download this from www.drivesnapshot.de/en and copy it into plug in directory named "C:\Program Files\pebuilder313\plugin\snapshot".
A slimmed-down version of the Firefox Web browser (Open Source) was developed especially for PE Builder and the mini-Windows Bart PE implementation. Click under the heading that reads "Computer, USB-Stick-Windows" to download this program. Unpack the contents of the file named "firefox-2.2.zip" into the plug-in directory named "C:\Program Files\pebuilder313\plugin" and the necessary sub-folders will be set up for you automatically.
McAfee's Stinger virus scanner (freeware) keeps track of the most dangerous Trojans and worms and gets rid of malware. Copy the file named "s-t-i-n-g-e-r.exe" into the folder named "C:\Program Files\pebuilder313\plugin\stinger".
The program known as Total Commander (Shareware, $34/28 €) is a Swiss army knife like utility, with built-in file management, compression, FTP and image viewing components. Install this software, then copy all files from its program folder into the folder named "C:\Program Files\pebuilder313\plugin\total commander\files". If you're a registered user of Total Commander, you'll also find a file named "wincmd.key" in its folder. Copy this file into "C:\Program Files\pebuilder313\plugin\total commander\files". Then, use a text editor to open the file named "totalcmd.inf" in the "...\plugin\total commander" folder, and delete the semi-colon at the start of the line that reads '\files\wincmd.key=a"[...]' (note: because the quoted value includes a double-quote mark, we used single quotes to designate this particular literal string).
HTML file with install data: You can see here how the imaging plug-in ghost is installed. Click to see a larger image.
Install folders for numerous other PE Builder plug-ins are pre-defined. In each such folder, you'll find an HTML file. Double-click each one to open it in your Web browser. There, you'll find information and instructions on how to add that program into PE Builder.
Warning: The more tools you add, the more storage space you'll need on the USB flash drive. The collection of items we've documented so far will fit on a 256 MB flash drive. If you've got a bigger device at your disposal, you can expand your portable rescue system. For example, you might also decide to include a data recovery tool, a disk partitioning tool and a software firewall.
Use your favorite search engine to look for "PE Builder plug-ins" to rummage around in hundreds of sites where additional plug-in information is indexed and described (our exploratory search on Google turned up over 74,000 hits; everything on the first few results pages looked pretty useful and interesting). Of these, Svenska's XpPe Boot CD site (www.xppe.com) looks like a great place to start hunting down plug-ins and information about how to use them.
To make Bart PE work on your PC, there are a few additional tweaks you must make to load the network interface and a DSL (or other Internet) connection.
Configure A DSL Connection
Configuring DSL: Enter your user name and password for access
If you want to use Bart PE to access the Internet, you must activate the freeware PPPoE plug-in and configure it for your DSL connection. Create a folder named "C:\Program Files\pebuilder313\plugin\pppoe_xp and extract the contents of the pppoe_xp.cab (Freeware) into that folder. To establish a PPoE connection, after you boot Bart PE you must also start the Network service and the PPoE service. Select "New Connect..." from the available options, accept the connection name you're granted, then provide your username and password as prompted.
With a pre-defined collection of plug-ins copied into the "C:\Program Files\pebuilder313\plugin" folder and the setup files for Windows XP in the "C:\sp2\winxp" folder, you've got everything you need to install Windows and additional utilities on the USB flash drive. Your next step is to generate the files for that drive. Here's how:
Launch this process by selecting "Start, All Programs, PE Builder, PE Builder". For the value of the Source field provide the Main window with the path to the XP Setup files at: C:\sp2\winxp. Leave the Custom: field blank, and leave the default value in the Output file (BartPE) intact. That will be the name of the folder that contains the USB flash drive files, in "C:\Program Files\pebuilder313\BartPE" in other words.
Click on the "Plugins" button at the bottom of the Main window, and check the resulting "Plugins" window to make sure that all the newly-added plug-ins covered in this article show a "Yes" value in the "Enabled" column. If that's not the case, highlight the name of that plug-in in the list, then click the "Enable/Disable" button to turn it on. PE Builder will check your settings, to make sure all of the necessary data is available, and will change the final status accordingly. At this point, you can include more plug-ins using the "Add" button, if you've downloaded more of them from the Internet. Click on the "Close" button when you're finished. Upon returning to the Main windows, make sure that the checkboxes next to "Create ISO image" and "Burn to CD" remain unchecked, then click the "Build" button. The necessary files will be generated at that point.
Load The USB Flash Drive
Using the Bart PE program: This command-line tool copies the configured version of Windows to the USB flash drive
Start the batch file named "peinst.cmd." You'll find it in the "C:\Program Files\pebuilder313\plugin\peinst" folder. It copies the files you generated using PE Builder onto the USB flash drive, as well as the Windows boot files. Open Windows Explorer and erase all files on the USB flash drive. Type 1 at the command line, then in response to the "Enter Source Path" prompt type the location of the generated Windows files: "C:\Program Files\pebuilder313\bartpe". Enter 2 at the command line, and provide the drive letter for the USB flash drive (for example E:). Start the installation by typing 5, then 1. The notification "Installation completed" appears when that process is complete. The USB flash drive is ready for use. If the PC won't boot from this drive, install a RAM disk as explained under the heading "RAM Disk for boot problems" that appears later in this article.
Using Your USB Flash Drive
There are many uses for your USB flash drive with Windows XP in emergency situations. Here are a few of the most important examples:
Virus Recognition And Elimination
Boot Bart PE from the USB flash drive, then start the virus scanner Stinger by selecting "Go, Programs, McAfee Stinger" from the menu. Use the "Add" and "Browse" controls to define the scanner's search targets. By repeatedly clicking on "Add", you can add additional path designations. To make sure Stinger checks the boot sectors, activate the "Boot sectors" option.
Stinger attempts to disinfect any infected files, if you elect the "Repair" option in the "On virus detection" field. If you elect the "Scan self extracting executables" option in the "Detection" field, you can also make sure the program will detect any compressed viruses hidden in executable files.
Back Up Disk Partitions
Drive-Snapshot: The trial version offers limited functionality, and can only capture disk images in the first 30 days after installation.
One uses Drive Snapshot to back up entire drives. The first time you start this program, it checks the calendar date. When the installed version ages past the trial use period, the tool's functionality becomes more limited. But you can install the commercial version any time you like. Grab the latest release from www.drivesnapshot.de/en/ . Copy the file named "snapshot.exe" into the folder named "C:\Program Files\pebuilder313\plugin\snapshot". Then, run the "peinst.cmd" batch file from the "C:\Program Files\pebuilder313\plugin\peinst" to write Barts PE Builder onto the USB flash drive.
Launch Drive Snapshot using menu entries "Go, Programs, Drive ShapShot" and click on the entry that reads "Backup Disk to File". That way you can capture a snapshot of the contents of one drive onto another. In the upper window, mark the partition you'd like to back up, then click "Next". In the next window, specify a storage location for the image file - for example, on an external USB drive. Enter a filename, then click on "Browse" to select a designation folder where the image file should be placed.
Click on "Advanced Options". In the field labeled "Maximum image single file size" you can set the maximum size for individual data parcels from the image file. For example, if you pick a size of 700 MB, it then becomes possible to distribute the image across multiple CDs.
Click on "Start Copy" to kick off the backup process. Test the completed image file: it should appear as a virtual disk drive, complete with drive letter. Then, click the main menu entry labeled "View contents of saved Disk Image" and pick a drive letter. Open the Total Command utility and use its "Map and Explore Virtual Drive" to inspect its contents.
The complete backup take the form of one or more SNA files, that you can even use with Nero to burn to a CD or DVD. Should a system crash ever occur, you can use the "Restore Disk from File" command to recreate the contents of that drive at the time the snapshot was taken.
The Total Commander utility also includes a pretty quick file manager with an integrated FTP client and compression software at your disposal. Start this program using the menu sequence "Go, Programs, Total Commander". Total Commander presents the contents of two disk drives, each in one half of its program window. You can use simple drag and drop moves to copy files from one drive to the other. For NTFS formatted drives, you'll also get a pop-up window that asks if you want to also "Copy NTFS permissions" - if you like, this lets you transfer the original permission settings along with the files. You can use this technique to rescue important files from a defective Windows installation and even retain secured copies of important documents on your USB flash drive. If you run low on storage space, use the integrated ZIP tool to compress files you want to rescue. Mark this files by pressing the [Strg] button.
Hard Disk Repair
If your PC won't boot, that might indicate a damaged or defective sector on your hard disk. Check the drive using the Windows Checkdisk tool, which is accessible on your flash drive through the "Go, System, Storage, Check Disk" menu sequence.
If you want to verify your PC's boot drive, enter "C:" when prompted to "Enter drive:". Answer the "locate sectors..." query by striking the Y key, to instruct Checkdisk to find defective sectors and attempt their repair. Strike the Y key one more time to launch the disk check. If repairs on damaged sectors fail, Checkdisk writes the readable contents of all such sectors to files, and stores them in the root directory of the checked drive. On a partially defective drive, there's still a good chance that you can save at last portions of the damaged files.
Rescue the saved files and sector images once the scan has completed by copying them to your flash drive. Should Checkdisk repair the defective sectors, you can keep using that disk drive. But should such problems recur in a short period of time, you'll want to replace that drive immediately thereafter.
RAM Disk For Boot Problems
When the computer won't boot from the USB flash drive, it's often because the motherboard initializes all USB ports during start-up. A RAM disk often provides an effective remedy in such cases.
A RAM disk works like a virtual disk drive and copies all of the files from the flash drive during boot-up, before it's fully initialized. That RAM disk also replaces the flash drive as the boot medium. To use a RAM disk you need Service Pack 1 for Windows Server 2003 (free) and the program Pe2usb.cmd (Freeware). Download Service Pack 1 (it's approximately 350 MB in size) into a folder of your choosing (for example, C:\server2003sp1". Create a subdirectory in your PE Builder folder ("C:\Program Files\pebuilder313") named srsp1 and copy the file named "C:\server2003sp1\i386\setupldr.bin" into that directory.
Open a Command window using the "Start, Run..." menu sequence, typing "cmd" into the Open: dialog box, then click OK. Extract the file named "ramdisk.sy_" into the same folder as follows:
expand -r C:\server2003sp1\i386\ramdisk.sy_ \pebuilder313\srsp1
Reformat your flask drive. To do this, click through the following menu sequence "Start, All Programs, HP Company," then select the "USB Disk Storage Format Tool". Select the USB flash drive from the "Device" list, select FAT at the file system, then click "Start".
Download the "Pe2usb" tool into the PE Builder file on your hard disk ("C:\Program Files\pebuilder313". Inside Windows Explorer, navigate to that directory, then drag the file named "Pe2usb.cmd" into a Command window and drop it there. The file with a complete path specification appears on the command line. Add the drive letter for the USB flash drive to this line, then launch the command with the Enter key:
After that, the USB flash drive is ready for booting.Glossary: What Does It Mean?
Bart PE: This slimmed down version of Windows XP fits on a CD-ROM or a USB flash drive. If your PC won't boot from the hard disk, you can then use a CD or the USB to boot your machine. Bart PE is generated from the original files on the XP Setup CD and the program files for a number of system tools, using the PE Builder program from Bart Lagerweij. The author retains all rights to this software, but the program is free and may be used and shared according to the terms of the PE Builder license.
Boot device order: (aka "Boot device priority" in some BIOS')
This collection of BIOS settings determines which device provides boot information to a PC. During system start-up the PC loads the boot sectors from the first operational drive it finds in this list. On hard disks, this means it loads the Master Boot Record (MBR). This contains the boot loader, which ultimately loads the operating system.
FAT file system: The partition format on a hard disk derives either from a File Allocation Table or a Master File Table, and specifies which files are stored on which sectors. A FAT formatted drive can be up to a maximum of 2 GB in size.
Plug-in: This combination of an executable program's files and a configuration file serves as the installation driver for a system tool in the PE Builder environment. But the programs available when Bart PE is running are not installed after the fact as in a normal Windows runtime environment. The user must specify all such items before PE Builder generates the mini operating system known as Bart PE.
RAM disk: This software uses the main memory on a PC as a virtual drive. It provides a workaround for PCs that initialize USB flash drives as part of their boot processes. When such a workaround is needed, the PC boots from the RAM disk instead of the flash drive.