O'Reilly Book Excerpts: Car PC Hacks
Hacking Your Car: Install Windows on a CompactFlash Cardby Damien Stolarz
Editor's note: This hack was written by Silvio Fiorito, who contributed it to O'Reilly's Car PC Hacks book.
Microsoft's XP Embedded OS can help you do what XP normally can't—boot off a CompactFlash card.
The car PC community is constantly searching for hardware and software solutions to improve the system's boot speed and reliability and reduce the physical size of the computer. One of these solutions is to build a system that boots off a CompactFlash (CF) drive. Flash storage is used in many commercial devices because it's small, has no moving parts, uses less power than a hard drive, and holds up much better than a hard drive when exposed to vibration and extreme temperatures.
Using only a CF-to-IDE adapter (Google "CF to IDE") and any off-the-shelf CF card (Figure 4-16), flash-based systems can be built relatively easily and affordably. One of the disadvantages of using flash, however, is that due to its construction it can withstand only a limited number of writes. This is fine for digital cameras, but since operating systems like to constantly thrash around on the hard drive with temporary files and virtual memory, flash requires special support by the operating system to filter out or completely disable these writes. Many users have turned to custom versions of Linux, while Windows users have had no viable option other than Windows CE or XP Embedded.
Figure -16. A CompactFlash-to-IDE adapter
For those willing to try, Microsoft provides a free trial of XP Embedded (XPe) from its web site that allows developers to build a fully functional boot image that will work for 90–120 days. It takes a few tries to get it working right, but it's a very powerful tool. After spending a good amount of time playing with it and reading as much as I could about it on Microsoft's MSDN site, I decided to investigate how XPe was able to work on flash disks. Since XPe is just a componentized version of XP, I figured there was no reason why a regular XP install couldn't be made to use some of the XPe components in order to boot from a CF disk.
Microsoft provides a component called the Enhanced Write Filter (EWF) for developers planning to deploy their systems to a CF disk. EWF is simply a storage filter driver that can be configured to protect one or more volumes from any unwanted writes. All changes to a protected volume are filtered by EWF, which then stores them in RAM rather than writing them to the disk. Upon system shutdown or reboot, changes can be either committed to the volume or discarded. Since the volume is not written to during normal operation, the system is also more resistant to data corruption in case of a sudden power loss.
MinLogon is a component Microsoft added to XPe for devices that need quick boot times and as little overhead as possible. Normally, when an XP system is booted, an executable called WinLogon is started that performs the user login, sets the security policy settings, and runs the logon scripts. This can be a lengthy process and seriously hurt boot times. Car PC developers don't typically need this level of functionality in our systems—we just want the system to boot up as quickly as possible and start playing music like a normal radio would. MinLogon was created for just these types of devices, and coupled with EWF, you can use it to turn a regular XP install into an OS capable of quickly booting off a CF disk.
The first step in preparing a CF install is downloading the XPe trial from http://msdn.microsoft.com/embedded/windowsxpembedded/default.aspx. The install will create a network share on your system called Repositories. This is where all the XPe components are stored, and all the files I use in this hack come from this directory. The best way to experiment with this hack without corrupting your desktop system is to use machine virtualization software, such as VirtualPC (http://www.microsoft.com/windows/virtualpc/default.mspx) or VM-Ware (http://www.vmware.com). Set up your XP install and make sure you've got a way to transfer files between the virtual machine (VM) and the desktop. After I set up my system in VirtualPC, I created a second VM using a differencing drive of the first VM. This was so that if I screwed up I wouldn't have to go through the lengthy reinstall process all over again. (See the VirtualPC documentation for directions on how to set up a differencing drive.)
If you have any disk-cloning software, such as Symantec's Ghost (http://www.symantec.com/sabu/ghost/), you can use that too. Clone the drive you want to experiment with onto some old 1-GB drive you have lying around, and try changing that version so that you can re-clone it if you mess it up.