The scenario. Available to me were:
* Legitimate Windows XP with SP1 setup CD.
* Target computer: has 1 blank Harddisk and can boot from USB. Aim to install XP here. No CD drive.
* "Work" computer: standard Windows 7 installation, used for preparation.
* Blank 1 Gb USB stick.
The restriction was that I could only use whatever tools are included in Windows 7 on the Work machine. No third party applications. In addition, I aimed to make the fewest possible tweaks along the way.
The steps that worked successfully to install XP from USB, exactly as written, from the first to last step. Some additional remarks are at the end.
Steps 1 - 5 are performed on the Work computer.
Steps 6 - 10 are performed on the Target computer.
Step 1) Partition and format the USB stick in Windows 7, which makes it bootable:
Start Command Prompt, start diskpart.
Enter commands: select disk 2, clean, create partition primary, active
Exit diskpart, unplug and replug the stick.
Format the stick via Windows Explorer (I chose FAT32).
Note: the value in "select disk 2" depends on the number of harddisks and other USB storage devices you have! You have to check what value is appropriate for your system (use "list disk"). I have two Harddisks and disconnected all other USB storage devices, hence the value is 2 for me (numbered from 0).
Step 2) Copy contents of Windows XP with SP1 setup CD in whole to the USB stick.
Step 3) Copy these files from \I386 folder to \ on USB stick:
setupldr.bin -> bootmgr (rename), ntdetect.com, txtsetup.sif
Step 4) Edit \txtsetup.sif to add two lines in [SetupData] section:
BootPath = "\I386\"
SetupSourceDevice = "\Device\Harddisk0\Partition1"
Step 5) Use Notepad to create a file named boot.hdd at \ on USB stick with these two lines:
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP" /fastdetect
Step 6) Boot from the USB stick on the Target computer. This starts the text-mode portion of Setup.
Follow the instructions on-screen, creating/formatting a partition on the Harddisk as needed in the process. Make sure to install Windows XP in the first partition, in the WINDOWS directory.
Step 7) When Setup reboots, reboot from the USB stick again and enter Recovery Console. If you try to boot from the Harddisk at this point, you'll get a hal.dll error.
Step 8) Using the Recovery Console, rename c:\boot.ini to boot.bak. Copy \boot.hdd from USB stick to c:\boot.ini
Step 9) Reboot, this time from the Harddisk. This starts the first GUI portion of Setup. Proceed as normal, but you are asked for the location of various files several times along the way. Each time answer with D:\I386, where D is the drive letter of the USB stick at this point. Trial and error works here. Have to do this about 20 times total.
Step 10) When setup reboots again, reboot from the Harddisk. This is the last GUI portion of Setup. Proceed as normal.
Done! This process took me 61 minutes from start to finish, which included 30 minutes for copying the contents of the CD onto the USB stick. The process is non-destructive in the sense that it does not modify the contents of the USB stick in any way.
* Using Windows 7, partitioning with diskpart and formatting via Windows Explorer is actually sufficient to create a bootable USB stick. The resulting stick will boot in most modern PCs, and a lot of older ones. When formatting, Windows 7 correctly enters drive number 80h in the BPB of the partition on a USB stick (unlike Windows XP, which enters 00h, leading to issues with bootability). However, creating a bootable USB stick is not always an easy or guaranteed process. It worked for me on my hardware, but your milage may vary.
* Conventionally, setupldr.bin is renamed to ntldr, but I had to use bootmgr instead, because naturally the VBR code placed by Win 7 loads that one.
* As is well-known, XP setup can be performed from a properly prepared local source on the USB stick, using $WIN_NT$.~BT/$WIN_NT$.~LS. What's less known is that setup can be booted and performed from *any* directory, using BootPath and SetupSourceDevice. These two settings are honoured if placed in txtsetup.sif in the current directory next to ntdetect.com. SetupSourceDevice overrides the need for a CD drive.
* The value of SetupSourceDevice can be any valid NT device path. When booting from a USB stick, the stick normally gets assigned as \Device\Harddisk0. The fun thing is that other paths also work, for example "\GLOBAL??\D:", where D is the drive letter assigned to your USB stick when booting from it. (Bit of trial and error needed here). The trick is that all Win32 device paths are actually a subset of all NT device paths, attached under \GLOBAL??. Note that paths other than NT device paths don't work (such as ARC paths, or direct Win32 paths such as "D:" or "\\.\Physicaldisk0".
* There is no need to prepare winnt.sif
* The deal with having to prepare a boot.ini file in advance and copy it over using Recovery Console is because of the ARC path problem arising from booting from USB, which leads to the (in)famous hal.dll error. Sadly Recovery Console doesn't allow file editing, so the correct boot.ini has to be prepared in advance. This issue is well-documented, so just in brief:
When booting from USB under XP (and its setup), the USB stick is assigned multi(0)disk(0)rdisk(0), and the internal harddisks are assigned multi(0)disk(0)rdisk(1) onwards. When booting from the harddisk, it is of course assigned multi(0)disk(0)rdisk(0). Since the setup was started by booting from USB, an incorrect boot.ini file is created on the harddisk (with a multi(0)disk(0)rdisk(1) entry). In order to correct this and allow booting from the harddisk, the boot.ini file on the harddisk needs fixing.
Edited by Legorol, 20 June 2011 - 08:12 PM.