102 - Speed up WinToFlash XP installs (+fix 'NTLDR is missing' error)

website statistics

Install XP to hard disk from a USB flash drive in under 5 minutes (for text mode copy phase) using an NTFS USB flash drive! Almost twice as fast as a FAT16 USB stick.

Introduction

WinToFlash can copy the contents of a Windows Install ISO or CD/DVD to a USB flash drive so that you can boot from the USB drive and install Windows to a target system (e.g. a netbook).
In this Tutorial, I will just deal with Windows XP installations.

If you have already tried WinToFlash but got an 'NTLDR is missing - Press any key to restart' error, or it would not boot correctly, or you find the installation of XP (1st stage copy files in text mode) verrrrry slow, you might like to try this method which greatly speeds up installation and may make it more reliable on a wider range of systems.

WinToFlash formats the USB stick as FAT32. When I tried to install XP from a WinToFlash USB stick on my Asus EeePC 904, the first copy files stage took over 79 minutes to copy the files from the USB drive to the internal hard disk!
Formatted using the WinToFlash FAT16LBA option took almost 8 minutes.
When I reformatted the same USB stick as NTFS however, the same stage took just over 4 minutes!

In all cases the target internal hard disk partition was quick formatted as NTFS.

To avoid BSOD 0x0000007B errors, if possible, change the BIOS hard disk options on the target system to IDE Legacy mode (not SATA - AHCI).
If you have a system that requires AHCI drivers or other Mass Storage Drivers that are not integrated into the XP install folder, you can use nLite to integrate the correct Mass Storage Drivers (.inf files).

How WinToFlash boots Windows XP Setup

The normal Windows XP boot process is explained here.

For WinToFlash however, the boot sequence is as follows:

The Master Boot Record (MBR = first sector on the disk) is read and the start of the active partition is found by looking at the MBR partition table values:

The Partition Boot Record (PBR) in the FAT32 volume of the USB drive produced by the WinToFlash format looks for and loads the file \NTLDR.

NTLDR parses the boot.ini entries and presents the menu to the user. The boot.ini file contains:

[Boot Loader]
Timeout=30
Default=multi(0)disk(0)rdisk(1)partition(1)\WINDOWS
[Operating Systems]
C:\$WIN_NT$.~BT\BOOTSECT.DAT = "1st, text mode setup (Boot from flash again after finished)"
multi(0)disk(0)rdisk(1)partition(1)\WINDOWS="2nd, GUI mode setup, continue setup + 1st start of Windows" /fastdetect
C:\ = "---> DEBUG, in case of HAL.DLL or NTOSKRNL.EXE not found errors <---"
multi(0)disk(0)rdisk(1)partition(2)\WINDOWS="Debug boot rDisk 1 partition 2" /fastdetect
multi(0)disk(0)rdisk(1)partition(3)\WINDOWS="Debug boot rDisk 1 partition 3" /fastdetect
multi(0)disk(0)rdisk(1)partition(4)\WINDOWS="Debug boot rDisk 1 partition 4" /fastdetect
multi(0)disk(0)rdisk(2)partition(1)\WINDOWS="Debug boot rDisk 2 partition 1" /fastdetect
multi(0)disk(0)rdisk(2)partition(2)\WINDOWS="Debug boot rDisk 2 partition 2" /fastdetect
multi(0)disk(0)rdisk(2)partition(3)\WINDOWS="Debug boot rDisk 2 partition 3" /fastdetect
multi(0)disk(0)rdisk(2)partition(4)\WINDOWS="Debug boot rDisk 2 partition 4" /fastdetect

The first entry in boot.ini is

C:\$WIN_NT$.~BT\BOOTSECT.DAT = "1st, text mode setup (Boot from flash again after finished)"

BOOTSECT.DAT is an exact copy of the Partition Boot Record of the USB FAT32 partition (e.g. LBA 63), however, it has been patched to load the file $LDR$ instead of NTLDR. Note that the error message that is displayed if $LDR$ is not found is 'NTLDR is missing Press any key to restart' and not '$LDR$ is missing - Press any key to restart'!

$LDR$ is a copy of setupldr.bin which starts the Stage 1 text mode Setup phase.

NTLDR is missing error

After preparing your USB flash drive using WinToFlash (if FAT32LBA), you may find that it does not boot on some systems and displays an 'NTLDR is missing' error.
This is believed to be due to the target system having a buggy, incompatible BIOS which does not use the standard 63 sectors per track and 255 heads per cylinder hard disk geometry.

The 'NTLDR is missing error' can be displayed at two stages of booting:

1. It is displayed when the code in the Partition Boot Record (PBR) runs and booting stops
2. If the PBR code works, ntldr will load and if the user chooses '1st' from the boot.ini menu, the bootsect.dat file will be loaded and run. The bootsect.dat file contains the same code as the PBR and so may also fail with the same 'NTLDR is missing error' error message.

To fix these two stages, we can patch bytes E6-E9 with four 0x90 bytes:

00E0 66 60 66 3B 46 F8 0F 82 - 4A 00 66 6A 00 66 50 06 f`f;Fø.‚ J.fj.fP.

then becomes:

00E0 66 60 66 3B 46 F8 90 90 - 90 90 66 6A 00 66 50 06 f`f;Fø.‚ J.fj.fP.

Note that when RMPrepUSB is used to format a FAT32 USB drive, these bytes in the PBR are already patched.

Instead of patching the PBR, we can install grub4dos which uses it's own boot loader and so we do not need to run the code in the PBR.
To patch the bytes in the bootsect.dat we can use dd in grub4dos (see menu below for details).

Requirements

  • Windows XP install files - this can be an ISO file which is mounted as a volume letter, or you can extract the files to a new folder on your hard disk using 7Zip or some other method.
  • WinToFlash
  • RMPrepUSB
  • (optional) Easeus Home Partition Manager

Method

1. First use WinToFlash to make your USB drive. Note that the contents of the USB drive will be lost when you do this.

This is the free version - just click the wizard button...

Now select the source (XP install CD or mounted ISO volume) and target (your USB Flash drive).

Tip: Select FAT16LBA in Advanced mode - it is much faster to install XP than the default setting of FAT32LBA.

Wait until WinToFlash has completed.

You now have a set of XP install files, however if you use these to install XP from a FAT32 Flash USB drive the install could be verrrrrrry slowwwwww...

If you are going to reformat the drive as NTFS (highly recommended as it is much faster!) then you can now skip steps 3 to 6 and jump to step 7.1.

The next steps (3-6) will help your USB drive to work on a wider range of systems but if it is FAT32, this will not fix the speed issue.

The first boot.ini menu option loads bootsect.dat which is a copy of the USB partition boot record which then tries to find and load ntldr. The code in this partition uses the disk geometry values embedded within it. This may match the actual disk geometry on the system that you are booting from or it may not - in which case you may get the 'NTLDR is missing' error message. To patch the code so that it does not use the embedded CHS parameters, you can manually edit the file with a hex file editor, boot directly to setupldr.bin or we can use grub4dos to patch the bootsect.dat file, as follows:

3. Install grub4dos using the Install grub4dos button in RMPrepUSB - make sure to choose MBR and press [Enter] to copy over the grldr file.

4. Add a file called menu.lst to the USB drive root - press F4 in RMPrepUSB and Notepad will create a new file for you. Cut and paste the following contents into Notepad and save the file. Ensure that the file is saved as menu.lst and not menu.lst.txt.


title Install XP using WinToFlash\nStandard WinToFlash install\nSelect 1st, reboot to this menu again and select 2nd
chainloader /ntldr

title Stage 1 - Install XP using WinToFlash\nUse if first menu gives NTLDR IS MISSING error after selecting 1st.
chainloader /$WIN_NT$.~BT/setupldr.bin

title Patch \\$WIN_NT$.~BT\\BOOTSECT.DAT\nUse this if you get an NTLDR IS MISSING error after selecting 1st.
set OS=
set BT=
# Note: this only works on FAT volumes as grub4dos cannot patch small <1K files on NTFS volumes!
if exist (hd0,0)/$WIN_NT$.~BT/BOOTSECT.DAT set BT=(hd0,0)/$WIN_NT$.~BT/BOOTSECT.DAT
if exist (hd1,0)/$WIN_NT$.~BT/BOOTSECT.DAT set BT=(hd1,0)/$WIN_NT$.~BT/BOOTSECT.DAT
if exist (hd1,1)/$WIN_NT$.~BT/BOOTSECT.DAT set BT=(hd1,1)/$WIN_NT$.~BT/BOOTSECT.DAT
if exist (hd1,2)/$WIN_NT$.~BT/BOOTSECT.DAT set BT=(hd1,2)/$WIN_NT$.~BT/BOOTSECT.DAT
if "%BT%"=="" pause --wait=3 Cannot find /$WIN_NT$.~BT/BOOTSECT.DAT && configfile /menu.lst
# detect OS
cat --skip=3 --length=0x52 --locate=FAT32 %BT% > nul && set OS=FAT32
cat --skip=3 --length=8 --locate=MSWIN4.1 %BT% > nul && set OS=FAT32
cat --skip=3 --length=8 --locate=MSDOS5.0 %BT% > nul && set OS=FAT32
if "%OS%"=="" pause --wait=3 Sorry - can't determine OS of BOOTSECT.DAT && configfile /menu.lst
echo FOUND %OS% at %BT%
cat --hex --length=0xf0 %BT%
set /p ASK=Press Y to patch file (Y/N):
if not /i "%ASK%"=="Y" configfile /menu.lst || echo -e \n\r
echo Patched file is now...
if "%OS%"=="FAT32" cat --skip=0xe6 --locate=\x0f\x82\x4a\x00 --replace=\x90\x90\x90\x90 %BT% > nul
cat --hex --length=0xf0 %BT%
echo Finished - press a key to boot to the WinToFlash installer...