WindowsDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


AddThis Social Bookmark Button

Hacking Your Car: Install Windows on a CompactFlash Card
Pages: 1, 2, 3

Pay special attention to the last entry, ArcName. That points to the volume you want protected. This script will default to the first partition of the master drive on the primary IDE controller, so as long as you have your CF card set as the master drive on the primary IDE controller you'll be fine.



The first few entries are optimizations for EWF-enabled systems. To minimize disk writes, we've disabled automatic defragmentation and prefetch. I also included a tweak to disable the NTFS last-access file timestamp. If you use NTFS on your system, you don't want the OS constantly updating timestamps for files you access and creating unnecessary disk writes.

Once the system boots, pull up a command line and run ewfmgrn:, where n: is the letter of the protected drive (typically "c"). The output should be similar to this:


Protected Volume Configuration
 Type            RAM (REG)
 State           ENABLED
 Boot Command    NO_CMD
  Param1         0
  Param2         0
 Volume ID       87 0B 88 0B 00 7E 00 00 00 00 00 00 00 00 00 00
 Device Name     "\Device\HarddiskVolume1" [C:]
 Max Levels      1
 Clump Size      512
 Current Level   1
  Memory used for data 1294336 bytes
 Memory used for mapping 4096 bytes

If instead you get an error stating that no EWF volume could be found, pull up the Registry Editor and recheck your settings, make sure that ewf.sys is in the System32\drivers directory, unplug any other hard drives, and restart.

ewfmgr gives you some important information about your protected volume and tells you how much RAM your overlay is taking up. That's an important factor to keep in mind: the more changes you make to your protected volume, the more RAM it'll take up, until you finally run out of memory. So be careful what you do to your system with EWF running.

Here are two important commands to remember:


	C:\ ewfmgr c: -commitanddisable –live

This will immediately disable EWF and commit all changes to the volume.And this command will enable EWF on the next bootup:


	C:\ ewfmgr c: -enable

The typical process for making persistent changes to your volume is to run the commitanddisable command, make your changes, run the enable command, and restart.

Another useful feature for car PC systems is what Microsoft calls "Hibernate Once, Resume Many" (HORM). If you have hibernation support enabled in your system, this basically allows you to hibernate your system once, and then always resume from that same hibernation state every time you boot up. This minimizes writes to the CF card and improves boot and shutdown times. All it takes is a simple file called resmany.dat on the root of your drive. Just create an empty text file and name it resmany.dat. When this file is present on the root drive, the EWF NTLDR knows not to reset the hibernation file as it normally would; thus, you never have to re-hibernate, unless you specifically request it. If you decide you don't want to resume from hibernation, just hit F8 while the system is booting to delete the restoration data and boot up normally.

The hibernation process bypasses EWF, so there's no need to disable EWF before you hibernate. However, make sure to disable EWF when you create the resmany.dat file, or it won't be written to the flash drive. (You'll then need to re-enable EWF and reboot before hibernating.) Most likely, you'll have an external drive containing your MP3s. Microsoft recommends setting the hibernation point without any other hard drives plugged into the system, because if the write cache still has data in it when you hibernate, every time you resume that data will be in the write cache and could potentially corrupt the partition. XP will automatically detect any new drives that are attached to the system, so once you set the hibernation point you can leave your drives plugged in.

Setting Up Your XP Installation

Now that you have successfully created an EWF system in a VM, you can start planning your final system. My recommendation is to first make a customized XP install, using a program such as nLite (http://nuhi.msfn.org/nlite.html) to remove any excess features you don't need. You want to get your XP installation as small as possible so that it can fit onto a CF card. You'll probably have to choose between a 512-MB or 1-GB card. Do some research, and try to find the fastest CF card you can afford. Keep in mind that if you plan on using hibernation, your space requirements will increase by the amount of RAM you install in the system. In other words, if your XP installation takes up 320 MB and you have a 256-MB stick of RAM, you'll use up about 576 MB of space and will need to get a 1-GB card. However, if you don't need hibernation, you can make do with a 512-MB card and save yourself some money. You'll also need to buy a CF-to-IDE adapter. Do a search on Google, and you'll find quite a few different adapters out there. Some can even plug directly into the IDE port rather than using cables, which saves space.

The best way to go about putting your XP installation on a CF card is to first set up your system on a regular hard drive. Load up all your drivers and third-party tools, make the necessary configuration changes, and of course install EWF and MinLogon. Once you're happy with the system, you need to initialize your CF card. Microsoft recommends using a FAT filesystem to improve the performance of EWF and minimize writes to the drive. Also, many retail CF cards come configured as removable drives, and as Windows XP will not allow you to partition and format a removable drive with NTFS, you must use FAT for these cards (although you can sometimes get a utility from the manufacturer to configure the CF card to appear as a fixed, or non-removable, drive).

XPe includes a special tool called Bootprep.exe that is used to enable FAT-formatted disks to boot into Windows XP. To configure a FAT-formatted CF disk to boot XP, you'll need a DOS boot disk with fdisk.exe, format.com, and bootprep.exe. Here's what to do:

  1. Start by installing your CF card as the master drive on the primary controller and your hard drive on the secondary controller.

  2. Boot into DOS and partition your disk, and then run the command format c: /s. This command formats the disk, and the /s switch copies over the DOS system files to make the CF disk bootable. Reboot, and if all goes well the system will boot into DOS from the CF disk. If not, you need to check your BIOS settings.

  3. Once you've confirmed that your CF card boots successfully, boot with your DOS boot disk (not the CF card) and reformat the card by using the command format c: (without the /s switch). Then use the bootprep /dc command (the /d switch specifies which drive to use) to run Bootprep.

If you are using NTFS, simply use Windows Disk Management to partition the drive and format it.

Now you are ready to copy over your XP install. Since Windows won't allow copying of files from the currently running OS instance, you need to boot into another OS, or attach both the hard drive and the CF card to another machine. Use whatever method you prefer, whether it's booting into Knoppix, DOS, or another XP installation. Just make sure that whichever method you use, it copies all hidden and system files and keeps the file attributes (hidden, read-only, archived, and so on) intact.

Once the transfer is done, connect your CF card to your system, remove all other hard drives, and boot up. As long as all the files were copied over properly, the system will start booting into your XP install, just as it did from the hard drive. Once the system boots up, take a look around and make sure everything is working right. Bring up a console by running cmd from the Start menu, and check that EWF is running.

With your system now running on a CF card, you have a small, fast, and reliable installation of XP to use for your car PC or any other small, embedded device you plan to use. I suggest you experiment a little by using the standby power function, as well as taking a look through Microsoft's MSDN site for embedded technologies (http://msdn.microsoft.com/embedded/) to see what tips they may have.

If you're going to be making significant changes to the system, you may want to consider doing it on the hard drive first and then redeploying to the CF disk. That way, you can clean out log files, temp directories, and any other leftover junk that'll take up precious space on your CF disk.

--Silvio Fiorito

Damien Stolarz is an inventor who's made different kinds of computers talk to each other for a decade. He co-founded Blue Falcon Networks to architect and develop networking software. In 2002, Damien created Robotarmy, a high-technology consulting firm.


View catalog information for Car PC Hacks

Return to the Windows DevCenter.