Sunday 9 June 2013

Windows 7 Deployment - Part02: Create Bootable WinPE USB Drive For Image Capture





Make the USB pen drive bootable:

  • Stick your USB drive in.
  • Run CMD prompt as Administrator.
  • Run 'diskpart'.
  • Run the following commands:
list disk
select disk 2  <-- (on my system, disk 2 is the usb drive. You need select the right one in your case.)
clean
create partition primary
select partition 1
active
format fs=fat32 label=image quick
exit

A sreenshot is shown below. My disk 0 is local hard drive, disk 1 is a USB hard drive. Disk 2, you can tell from the size, is my USB flash drive.


Now the USB drive is bootable. Done! Note that you only need to do it once for this USB drive to be bootable, until someone makes it non-bootable.



The next step is to copy the relevant files in to make it a WinPE disk.

Go to Start -> Microsoft Windows AIK, and run the command prompt as Administrator.




In the command prompt, if you run a dir command, you will see something like this:

amd64, ia64, x86 are the WinPE files for different hardware architecture. I run 64bit machines, so I need amd64. Google 'amd64 vs ia64' to see what you require.

You can use manual copy command to copy the relevant files into your USB drive. Or you can use 'copype.cmd' provided by AIK to do the job.

The syntax of copype.cmd is like:

  copype.cmd <arch> <destination>

Let's use c:\winpe folder for our purpose. Type in the following command. Note that I use amd64.

    copype.cmd amd64 c:\winpe

(If this is not the 1st time you run it, and c:\winpe exists already, you can delete the folder from the windows explorer.)

Running the script creates the following directory structure and copies all the necessary files for that architecture. For example,
c:\winpe\iso  <-- holds the 'prodution' content that will go in the bootable USB flash drive or CD.
c:\winpe\mount  <-- mount point.



Add further customization

Add ImageX.exe. ImageX.exe is platform dependent, hence you need to add the right one for your system, i.e. x64 or x32? Go the the right location, e.g. in our case of 64bit system, C:\Program Files\Windows AIK\Tools\amd64, run
  copy imagex.exe c:\winpe\iso

NB: at this stage, you can also inject network driver into the WinPE image, so that when you boot your machine up using the USB drive, you can use 'net use z: \\<server>\<folder>' etc to access network files. See the end of this article for steps.

Now everything you need is gathered together.

In your windows explorer, go to c:\winpe\ISO folder, select all the files, and copy them to your USB pen drive.

You can now boot your reference machine from this usb drive to WinPE mode, and use ImageX to capture the image into a WIM file.


Alternatively, if you are short of USB pen drives and wish to use a CD/DVD (to me it seems a waste of plastic), you can do so by running the following command:

  oscdimg -n -bc:\winpe\etfsboot.com c:\winpe\ISO c:\winpe\winpe.iso

This will produce a ISO file, c:\winpe\winpe.iso. You can now burn it to a CD.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Optional: Inject device drivers to offline image using DISM


Our winpe image as created above resides in c:\winpe.
Put your device drivers in, say,  C:\drivers\latitude.

To inject driver to the winpe image:

  Dism /image:C:\winpe\mount /Add-Driver /driver:C:\drivers\latitude /recurse

To double check what drivers have been injected:

  Dism /image:C:\winpe\mount /get-drivers

Commit (save) the changes:

  Dism /Unmount-Wim /MountDir:C:\winpe\mount /Commit

Since the files in c:\winpe\ISO is the 'production' content that will go into a bootable USB flash drive / bootable CD/DVD, we now need to update the 'produtction' image to the new image we just modified:

  copy c:\winpe\winpe.wim c:\winpe\iso\sources\boot.wim

You can now copy the files in c:\winpe\ISO to your bootable USB pen drive, say, E:\. You can also do it in command line:

  xcopy C:\winpe\iso\* /e E:\



(It seems a lot of steps. But you only need to do it once, and re-use the USB drive over and over again)


No comments:

Post a Comment