Sunday, October 17, 2010

It Worked for Me - Building a Bootable USB Thumb Drive for Windows 7 Install using the Dell Factory Image.

This process took me a while to work out.  It all started when I purchased a slightly used system from my local computer store.  It was licensed for Windows 7 Pro x64 but was running Windows XP.
At the time I didn’t have a set of Windows 7 Pro x64 disks and the recovery disks I had for the existing system kept hanging during the disk format stage when trying to recover on the new system.
In order to get around both these problem I figured out that I could like the factory image from the first system and then build a bootable usb thumg drive and do the install.

The process took four stages:

1. Setup the usb thumb drive.
2. Download the Windows Automated Install Kit (WAIK) and then building the source files for a CD.
3. Configure the system drive on the target system.
4. Copy the source files onto the usb thumb drive and installing.

It took me a couple of times to run through all the steps and get it right.  I am sure there are other ways to do this and probably better ways but this is what worked for me.

Format usb thumb drive using the following commands in the DISKPART utility.  Be careful any data on the thumb drive will be erased.

Determine what drive your usb thumb drive is using the “list disk” command in DISKPART and looking for a drive that is the size of your thumb drive.


In this case my usb thumb drive is drive 6.

Using the following commands setup the thumb drive.

select disk 6
create partition primary
select partition 1
format fs=ntfs quick

Download the Windows Automated Installation Kit (WAIK).  This will allow you to build a set of directories that contain the files necessary to boot a system.

I used the commands from the article on this website.

CD "C:\Program Files\Windows AIK\Tools\PETools"
CALL copype.cmd x86 c:\winpe_x86
copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim
copy "C:\program files\Windows AIK\Tools\x86\imagex.exe" C:\winpe_x86\iso\
oscdimg -n -bC:\winpe_x86\ C:\winpe_x86\ISO C:\winpe_x86\winpe_x86.iso
rem To remove the "Press any key to boot from CD" 
rem prompt during boot, remove the bootfix.bin file from 
rem the \boot folder within your mounted image. 
Note that the third, fourth and fifth lines wrap to a second line in the blog post.
Copy the files from c:\winpe_x86/iso\ to the root of your usb thumb drive and you should now have a bootable usb drive.

I grabbed a copy of factory.wim and factory2.wim off the recovery partition of another Dell running Windows 7 Pro x64 and put them on the USB drive in a dell directory.

Next I booted the new system using the usb thumb drive and setup the hard drive on the new system using DISKPART.  I setup the hard drive as a duplicate of the other similar system I had.  Based on this I ended up with a 50MB partition, 15GB Partition and the rest of the disk drive.

I used basically the same steps as I had with the usb thumb drive except in this case I was on disk 0 and there were a couple more partitions.

I am not exactly sure what happens to the first partition.  It ends up getting labeled as OEM and becomes inaccessible.  In my case the second partition will be used for a recovery partition.

select disk 0
create partition primary size=30
create partition primary size=15360
create partition primary
select partition 2
format fs=ntfs quick label=”RECOVERY”
set id=27
select partition 3
format fs=ntfs quick label=”OS”

If you want a recovery partition it needs to be set id-27 to make it hidden and it must come before the OS partition.  See the following information from Microsoft.

I then used the imagex command below to install the files onto the system.  In my case the usb thumb drive sometimes was e and other times i.
imagex/apply /ref e:\dell\image\factory2.wim e:\dell\image\factory.wim 1 c:

Note that the command line wraps in the blog and should all be typed in as one line.

I rebooted and the system started the final steps of the installation process.

A couple of times when I ran through this the system didn’t boot.  To fix this I inserted a recovery CD and run through it twice.  First it would find something and fix it.  The second time I would have to go to the fix startup option on the menu and it once again find something and then boot properly into the install.

As I mentioned for some reasons the recovery CDs I have built with my first Dell system would work on the new one.  Searching across the web I found someone who had a copy online and was able to  use that.

As I mentioned at the top of this post I expect there are better ways to do this but as this worked for me I wanted to post it to keep it around for my use and if it can help someone else out so much the better.


PRAJNITH said...

Do you have any info about what is the use of factory2.wim
Is it necessary to copy that along with factory.wim

digitalhack said...


My assumption was that both were needed and that the factory2.wim was a continuation of factory.wim.

I did not test this assumption so I cannot really say for sure.


Anonymous said...

I had 3 .wim files ie. Factory.wim, Factory2.wim and Factory3.wim

This command worked for me f:\imagex /check /verify / apply /ref g:\dell\image\factory*.wim g:\dell\image\factory.wim 1 C:\
f: being my usb stick with windows PE
and g: being my external hdd with the factory.wim files