Samstag, 19. April 2008

Putting Windows XP on a SD-Card

I wanted to test Windows XP on my EeePC but didn't want to loose my fine-tuned Ubuntu on the internal SSD. My first try following some guides on the net wasn't successful, Windows always wanted to modify data on the SSD. So I had to mix up things I found on the net to finally get it to work. I have Windows XP booting of an SD-Card in the internal card reader now and had not to destroy any data that was already on my EeePC. The information about how I got it to work might be useful for others as well so I decided to write down what I did.

What do you need for that?

* A Windows XP installation CD and a valid key, of course.
* An external USB-Drive (can be a USB-Stick, but a USB-HDD was my "sure bet")
* For making the USB-Drive bootable you can use the HP-tool which is included in the BIOS-updater-archive from Anarethos
* Microsofts CAB-SDK
* The Hitachi Microdrove driver for pretending that the SD-Card in the Card Reader is a harddisk / fixed drive
* Drivers from the EeePC-DVD
* You may need this hotfix for support of SDHC cards with more than 4 GB capacity from Microsoft
* For changing the display resolution to for example 1000 x 600 pixels (scaled, but quite readable): AS-Tray Plus

Some of these tools stem from users that I don't know and therefore can't trust. I scanned all the executable files I used from them with Virustotal to make sure they aren't infected with a backdoor or something similar. Of course the files aren't guaranteed to be clean, but as all those virus scanners didn't find anything suspicious it made me feel a little better. Since those archives and tools are updated every so often, you should scan them as well before using them.

First, I created a partition which is a little bit smaller than my SD-Card on the USB-HDD, in my case I used a 3800 MB FAT32-partition. To make the USB-HDD bootable, I used the HPUSBF.EXE from the BIOS-Update-Tool-Archive. The syntax in my case was:

hpusbf.exe <drive-letter of my USB-HDD> -FS:FAT32 -B:<drive letter and full path to the unpacked BIOS-Update-Archive>\Boot -Y -Q

i.e.: hpusbf.exe F: -FS:FAT32 -B:D:\EeeBIOS\Boot -Y -Q

Then I copied the i386-folder from the Windows XP installation CD to my USB-HDD. There I changed the files DOSNET.INF, TXTSETUP.SIF,
USB.IN_, USBPORT.IN_ and USBSTOR.IN_ according to the description in this guide from Ngine (starting at point 4 of the guide) and created the new file USBBOOT.INF. After applying the changes I copied the modified and newly created files into the i386-folder on my USB-HDD. Some people seem to use a tool called XP3eSD which should do that patching automatically, but it didn't work for me. Although I found the correctly modified files in my users temp-directory – you might want to try that if that patching by hand is too much of a hassle for you.

Another hint I found was to put the files boot.ini, NTDETECT.COM and ntldr to root directory of the USB-HDD. The Windows-Installer will accept a drive with those files in the root-directory as installation-target. You can use an empty boot.ini, or copy the file from an existing Windows XP installation. Using this configuration will install Windows XP, but it'll take ages. So I also placed a tool which was useful back in those good old DOS times on the drive as well: smartdrv.exe.

Now you're ready for booting from the USB-HDD and to install Windows XP to it. You have to press the "ESC"-button after powering on the EeePC and get presented a boot-menu where you can choose of which device you want to boot from. Choose the USB-HDD. At the DOS prompt, enter smartdrv. To start the installation, enter i386\winnt.exe. This will start what looks like a usual Windows installation. You have to select where the source files are though and where you want to install Windows XP – both times choose the USB-HDD.

After the installation is finished, you should remove the i386- and the boot-folder. You should also convert the drive to NTFS; I didn't encounter any problems with the journaling capabilities of NTFS. Windows will complain about the missing swapfile. You should disable swapping entirely by choosing "properties" after a right-click on "My Computer". You find the settings on the advanced-tab of the Performance Options, select "virtual memory" there and make it use "no paging file".

At this point you should make a snapshot of the partition as the following changes will destroy the possibility to boot the installation of a USB-Stick or USB-HDD. Also, you can use that image to apply for example the upcoming Service Pack 3 for Windows XP. I booted into linux and made sure the Windows-partition is unmounted and used dd for the backup:

dd if=/dev/sda of=/mount/backup/eeewin-bootsector.iso bs=512 count=1
dd if=/dev/sda1 of=/mount/backup/eeewin-usb-hdd.iso

Then I went fetching a coffee and watched an episode of The Simpsons – creating that image of the partition may take a while. After that, you can boot into Windows again. Now you need that Hitachi Microdrive driver. The download can take a while even if the driver is extremely small. Extract the driver.

Run regedit and go to "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\". There should be a subtree called "Disk&Ven_USB2.0&Prod_CardReader_SD0&Rev_0100". Double click the key "Hardware ID" on the right pane and select the first line and copy it. Now open the file cfadisk.inf from directory where you extracted the Hitachi Microdrive driver to. Remove all entries in the section "[cfadisk_device]". Add a new line which starts "%MicroDrive_devdesc% = cfadisk_install," and paste the copied line from the registry in there. Save the file.

Now you have to open the device manager. In the "disk drives" section you should see the SSD as SiliconMotion and the USB2.0 Card Reader. Right-click on the Card-Reader-entry and choose to update the driver. You have to select a manual installation and force the installation of the .inf-File that you just changed. Now the driver gets installed.

If you reboot now, you could run into the problem that Windows won't start from the USB-HDD anymore. So now boot into linux again and copy the Windows partition from USB-HDD to the SD-Card. I used GParted which I installed from the Ubuntu repositories. You can copy the whole partition with that to the SD-Card and after that resize the partition to completely use all space on the card.

The SD-Card might not boot yet. So it's time to copy the boot-sector over to it:

dd if=/mount/backup/eeewin-bootsector.iso of=/dev/sdc

Make sure that the SD-Card really is /dev/sdc. You can do that by checking the system messages with the command dmesg at the console. If you have done all that you can unmount and unplug the USB-HDD and boot from the SD-Card and fine-tune your fresh installation. You might want to run Windows Update for example. After applying all updates you should delete the directory \Windows\SoftwareDistribution\Download. You may remove all those $NtUninstall-folders in \Windows\ as well. That'll save about a whole GB of space on the SD-Card.

3 Kommentare:

pelasg hat gesagt…

As far as I know flash cards have a much shorter life time - the number of rewrites is drasticaly limited as compared to a HDD.
And Windows is constantly writing stuff to the disk, so yes, Windows can run from the card, but how long before Windows trashes the card? Several weeks I guess.

Anonym hat gesagt…


Thank you for your tutorial. I am trying to follow your instructions to install WinXP on the SDHC card, using a USB Key (instead of a USB HD).

I have a question on this part : "After the installation is finished, you should remove the i386- and the boot-folder" : what do you mean by "the boot folder" ? I don't find any "boot" folder on my USB Key.


Livestrong2209 hat gesagt…

If you do try this you need to disable the disk catch because you will kill kill kill your SD card as well as drastically reduce the speed of your install,

Use TinyXp as it will allow you to install directly to the card and has a reduced foot print so it will require less ram, making up for the lost disk catch.

I have it running dual boot on my NC10 (320gb Mac / 16gb SDHC Win TinyXp)