Tuesday, March 19, 2013

How to install Windows XP from a bootable USB drive

This tutorial describes how you can boot to WinPE v2 or v3 from a USB drive on your 'target' system, then partition and format the hard disk and then install XP onto that hard disk. This method is slow as you have to run the complete Win XP Setup process, both the text mode part and the GUI part, which takes about 20-30 minutes.

You can choose from several different XP installations by placing each i386 XP CD source folder into a separate folder on the USB drive and installing the one that you want onto the target hard drive.

Outline of the Method


  1. Create a bootable WinPE USB drive
  2. Copy any Microsoft Windows XP CD (or XP ISO contents) to a folder on the USB drive
  3. Boot using the USB drive on the target system and wipe, partition and format the hard disk
  4. Copy the XP (32-bit version) files to the hard disk from the USB drive
  5. Run winnt32.exe (the file will be on the hard disk after copying from the USB drive)
  6. Reboot and allow XP Setup to continue


1. Download and install the Windows 7 WAIK to obtain the ImageX utility and WinPE files

  • For instructions on how to do this, please refer to the first part of my tutorial here or follow the Make_PE3 tutorial.
  • Follow the instruction up to the point where a WinPE folder has been created (Step 1)
  • You can create either an x86 version (recommended) or an amd64 (64-bit) version.
  • Create a new folder C:\MYXP on your office computer.
  • Copy the c:\pe86\ISO folder contents to C:\MYXP (C:\MYXP should now contain bootmgr, folders \boot, \sources, \efi, etc.)

2. Obtain a Microsoft Windows XP installation CD or ISO or set of NLited files that you wish to install
    Create a new folder on your Windows (office computer) hard disk called C:\MYXP\XPPRO\i386   (assuming you have XP Professional)
    Copy all the files in the CD's i386 folder to C:\MYXP\XPPRO\i386 folder
    Ensure that the file C:\MYXP\XPPRO\i386\unattend.txt is present and has been correctly modified by you (see end of this page for an example)

Note: XP does not contain AHCI or some SCSI/SATA drivers - either you must set your BIOS menu for Hard Disk mode to  'compatible/legacy' hard disk mode or you must use a specially modified version of XP (e.g. use nLite).

Now prepare a WinPE v3 (bootmgr) bootable USB drive using RMPrepUSB and copy over the C:\MYXP folder to the USB drive -  please refer to the part 2 of my tutorial here. Note: NTFS formatting is recommended for speed.

The USB drive should now contain an \XPPRO folder as well as the winpe folders: \sources, \boot, etc.

3. Boot from the WinPE USB drive using the target system that you wish to install Windows XP onto.

    Now run DISKPART and type the following commands (assuming you want a two partitions on the hard disk) - only type the commands in red:

  •     DISKPART    -    run diskpart utility
  •     LIS DIS          -   lists the disks present
  •     SEL DIS 0     -    select disk zero  (usually the first hard disk)
  •     CLEAN          -   wipes the selected disk
  •     CRE PAR PRI SIZE=30000 ALIGN=16065    -   create a 30GB primary partition for XP (change as  required) - if this gives an error use 64260 instead of 16065.
  •     FOR QUICK  LABEL=SYSTEM     -    format it as NTFS (add FS=FAT32 if you don't want an NTFS partition)
  •     ASSIGN  LETTER=J      -    assign it the drive letter J:
  •     ACT                                -    make it the boot partition
  •     CRE PAR PRI                 -    create another NTFS partition of remaining size (optional)
  •     FOR QUICK                  -    format it  (optional)
  •     ASSIGN                          -    assign it a drive letter  (optional)
  •     LIS VOL                         -     list volume letters
  •     EXIT                                -     quit diskpart


you now should have a formatted hard disk ready to receive files.

4. Now copy the files from your USB drive to the bootable partition you have just created:
    type XCOPY /herky F:\XPPRO\i386\*.* J:\i386\*.*

5. Now you need to run winnt32.exe to start the first phase of XP Setup as follows:
    type J:
    type cd \i386
    type winnt32 /unattend10:J:\i386\unattend.txt /syspart:J: /tempdrive:J: /s:J:\i386 /noreboot

Alternatively, if the i386 files are on the USB drive (i.e. not in an ISO or on the network), you can skip step 4 and 5 and just use the  following command line (this is much quicker and saves copying the files!)

J:\i386\winnt32.exe /syspart:J: /tempdrive:J: /makelocalsource

(thanks to João Santos for this tip!). You can use different source paths if you wish - e.g. J:\XPHOME\i386  and J:\XPPRO\i386 and change the winnt32.exe path accordingly.

6. When the setup phase completes and returns you to the command line you can reboot by typing:
    wpeutil reboot

Now remove the USB drive and allow the target PC to boot to complete the 2nd XP setup phase. Note that unless you have added AHCI drivers, the BIOS must be set to IDE (compatible) mode or you will get the dreaded BSOD 0x0000007b error!

TIP: The XP files are many and the file copy is thus quite slow (and very slow if using FAT32 on the UFD). You can speed this up by using 7zip instead of a file copy. Just zip up the XPPRO folder and place the zip file on your USB drive instead of the XP I386 files, then extract the files to the hard disk using the 7zip e or x option. You can also extract a zip file from a network as pulling a zip file across a network is a lot less data than pulling over all of the i386 files and therefore much faster!

Tip: You can easily automate the steps from 3 to 6 - e.g.

diskpart /s dp.scr
xcopy /herky \XPPRO\i386\*.* J:\i386\*.*
J:
cd \i386
winnt32 /unattend10:J:\i386\unattend.txt /syspart:J: /tempdrive:J: /s:J:\i386 /noreboot
echo Finished - please remove your USB drive now!
wpeutil reboot


where the file dp.scr contains the diskpart commands in step 3 (except for the first DISKPART line, of course).

WinPE has networking

The i386 files do not need to be on your USB drive, they can be on any networked computer. Just create a shared folder on your 'office' PC  (or server) - right-click on the C:\MYXP folder and choose 'share with' to share it out.

The WinPE USB drive will need to have the correct network drive for the target system.
To install the correct network driver when you have booted to WinPE from your USB pen, type DRVLOAD F:\WIN7DRIV\xxxxx.inf  where the USB drive folder F:\WIN7DRV contains the correct win7 driver files (.inf, .sys, .dll, .cat etc.) for your hardware (wait a minute or so afterwards for networking to start up). Now connect to your networked shared folder on your office PC using the command:
NET USE N: \\mypc\MYXP U:myworkgroup\myloginname  [Enter]
and then type in your password when prompted.
Now dir N:  should list the contents of the MYXP folder on your office computer. So you can now install any XP image across the network and you don't need the XP files on the USB drive at all, just change the XCOPY source folder in the example above to point to your N: network folder.

Another tip is to back up the XP install once it has finished installation. Then you can easily and quickly restore your XP install at any time in the future - see Tutorial #1 for details!

SAMPLE UNATTEND.TXT FILE FOR UK

;SetupMgrTag
[Data]
    AutoPartition=1
    MsDosInitiated="0"
    UnattendedInstall="Yes"

[Unattended]
    UnattendSwitch=Yes
    WaitForReboot=No
    UnattendMode=FullUnattended
    OemSkipEula=Yes
    OemPreinstall=Yes
    TargetPath= *
;Driver INF files placed in the following folders will be automatically installed
    OEMPnPDriversPath = "Drv\Net;Drv\Audio;Drv\monitor;Drv\Storage;Drv\Video;Drv\Mbd;Drv\Modem;Drv\Misc"

[UserData]
    FullName="Ted"
    OrgName= "Ted plc"
    ComputerName= *
;put your product key on the next line or delete the next line
    ProductID=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
   
[GuiUnattended]
    AdminPassword=*
    OEMSkipRegional=1
    TimeZone=85
    OemSkipWelcome=1
    AutoLogon=Yes
    AutoLogonCount=99

[TapiLocation]
    CountryCode=44

[RegionalSettings]
    LanguageGroup=1
    Language=00000809

[Display]
BitsPerPel = 16
XResolution = 800
YResolution = 600
VRefresh = 70

[Identification]
    JoinWorkgroup=WORKGROUP

[Networking]
    InstallDefaultComponents=Yes

[GuiRunOnce]

[Branding]
BrandIEUsingUnattended = No
IEBrandingFile = install.ins

No comments:

Post a Comment