Creating a Windows PE Boot disk

Posted by kyle on August 14th, 2007 filed in Vista Deployment, Vista Tips 'n Tricks

I have a USB stick (just upgraded to a 4Gb version) that I carry with me – it is a Windows PE boot disk with a Windows Vista Image on it (amongst other useful bits and pieces). Why? so that I can quickly and easily demonstrate the deployability of Windows Vista – yes I know.. I need to get out more!

I realised the other day that I had not actually gone through the steps to create a Windows PE USB boot disk – so here it is! (the same idea goes for creating a bootable image full stop – ie creating a bootable DVD, PXE boot file, etc)

Before you begin you need the ingredients:

Windows Automated Install Toolkit (WAIK)
A USB stick (depending on what else you want on it will depend on the size that you need – minimum of 512Mb – if you want a Windows Vista image on it then go for a minimum of 2Gb)

Steps:

  1. Install the WAIK (it is delivered as an .IMG file from the download site – either burn this to a CD or mount it using a tool such as VirtualClone CD)
  2. In the Start menu – navigate to All Programs/Microsoft Windows AIK and run the Windows PE Tools command prompt as an Administrator
  3. At the command prompt – create a temp directory – such as MD c:\temp then run set temp=c:\temp  and set tmp=c:\temp
  4. run copype x86 c:\PEBuild (this copies the PE Source to a new directory that we will use for constructing our image- if you needed the AMD64 source then replace x86 with amd64)
  5. At the command prompt (notice you are now in the c:\PEBuild directory) run imagex /mountrw winpe.wim 1 mount (this mounts the WinPE image file in the mount directory ready for us to add into)
  6. So that we have the imagex and deployment tools available in our PE Boot disk, run xcopy “c:\Program Files\Windows AIK\Tools\x86\*.*” mount\ /s
  7. At this point you could add other files into the image (such as Ghost tools, PMenu, etc) by copying them into the mount directory – you can also use the peimg command at this point to install other support tools such as scripting and HTA support – run peimg /list mount to see the full list and then peimg /install to install new support
  8. Once you are ready to seal the image up then run peimg /prep mount - this will ensure that the WinPE image is optimised – you will need to agree to seal it
  9. After sealing the image you then need to unmount it – imagex /unmount mount /commit
  10. To place the newly created custom WinPE image into the correct folder that we can then call on to create the boot disk – run copy /y winpe.wim iso\sources\boot.wim
  11. To create a bootable ISO file that can then be used to boot into WinPE, change back to c:\Program Files\Windows AIK\Tools\PETools and then run the following command oscdimg.exe -n -b"c:\Program Files\Windows AIK\Tools\PETools\x86\boot\etfsboot.com" c:\PEbuild\iso c:\PEBuild\PE.iso

So – you now have an ISO file that you could burn to a CD or DVD but the idea of doing all this was to get a bootable USB device.. so here is the final step.. grab the USB disk – and then use the following diskpart commands (be warned – check the disk that you are going to be using is disk 1 or if not then use the correct one for your circumstance – the clean command is a clean of the disk IT WILL DESTROY THE DATA ON THE DISK THAT YOU SELECT CHECK BEFORE PROCEDING!):

diskpart
select disk 1
clean
create partition primary size=
select partition 1
active
format fs=NTFS
assign
exit

After completing the disk clean and creating the format – then copy the contents of c:\PEBuild\ISO directory to the USB Stick.

If you are wanting to be able to do local deployments – then the final step is to add in the WIM file that you want to use (Vista, XP, 2003 etc).

You are now ready to boot off your USB stick and capture or install WIM files!


56 Responses to “Creating a Windows PE Boot disk”

  1. Alonzo smith Says:

    Hello,
    I am try to place a WinXP image “OS.wim” on a USB key. I create the USB key per the instruction, with not added plug-ins. I was not able to get dispark to see disk 1 my USB key.

  2. kyle Says:

    Hi Alonozo

    The example of disk 1 being your USB key was just that – an example.. it maybe disk 1, 2, 3, etc.

    Use the select disk command to select the disk – so select disk 1, select disk 2, etc.

    To ensure you have the right disk – try using detail disk (after selecting) – this will then show you the details for the disk – if it not the right one then select a different one – not an exact science granted – but it does work.

    Cheers
    Kyle

  3. Leigh Simcox Says:

    Hi,

    I have exactly the same problem. I followed all the instructions and it worked great until I got to the diskpart bit. I plug my flash drive in, which is already NTFS formatted, and then fire up diskpart. I use the list disk command and it only lists my hard disk, which is disk 0. I tried select disk all the way up to 6 but it finds nothing.

    Kind regards

    Leigh

  4. Jonathan Says:

    Kyle

    I have created a bootable pe usb key, with the standard diskpart commands, then xcopied the iso folder to the usb drive. This boots fine. What I now want to do is deploy my LiteTouch image(s) created in BDD (WAIK). What do i need to do to go from standard usb boot to bootable vista deployment from usb.

    Thanks
    Jonathan

  5. David Says:

    Kyle,

    This is the most fabulous way to get WinPE onto USB. Thanks!!

    I could never figure out how to get the sequence quite right.

    Is there a way to generalize this to get any iso that would be CD-bootable to be USB bootable?

    I confess that I don’t know enough about what is happening with oscdimg command to know whether it is only going to help with WinPE ISOs.

    Thanks

    db

  6. David Says:

    Just one follow-up…

    If you want to use the whole USB drive, just leave off size=

    db

  7. tom Says:

    Well I think I see what Alonozo is saying. I have a cruzer 2gb usb key, and it does not show up in diskpart as a selectable drive. The only drive that shows up is the harddrive. I am using xp, so maybe it’s a vista thing.

  8. tom Says:

    I’m gonna check it out tomorrow when I have access to a vista box, but I think the reason Alonozo and I are having problems is because we’re using xp… well at least I am.

    I was finally able to get this USB key by doing the following. Not 100% sure that every step is needed.

    1- downloaded the HP usb drive format utility
    2- formatted usb drive 2 make it bootable
    3- used convert command to convert drive to ntfs
    (at this point it still wouldn’t boot)
    4- used bootsect /nt52 on the USB drive
    (still not booting)
    5- renamed bootmgr to ntldr
    6- BAMN, boots.

    Now in windows PE, it does see the usb drive in diskpart as a disk. fyi.

  9. Scott Says:

    Upon CD bootup, only a c-prompt window is opened. I see the background, but nothing else is available to select. If I close the c-prompt window, my pc reboots. What might be the issue?

    I followed every step, except this command line (xcopy “c:\Program Files\Windows AIK\Tools\x86\*.*” mount\ /s) generated an error (invalid parameters), I assume though that what was needed were the contents of the x86 folder copied to the root directory of PEbuild, which I did.

  10. Scott Says:

    Nevermind…I discovered that’s how is should be. I thought there was going to be a GUI.

  11. Chuck Says:

    I have teh same problem. Most of my thumb drives show up as removable media and cannot be selected as a disk. Proably because they are cheap. I dont know. Only 1 of my thumb drives shows up as a disk but its only a 128mb. Any suggestions on useing it with removable media thumb drives?

  12. Vista booting and running from a USB Disk « Musings in Code Says:

    [...] http://www.vistapcguy.net/?p=71 [...]

  13. Phil Says:

    You can only make a usb device bootable from a machine running Vista. Diskpart in Vista is the only client OS that will see the USB device as a separate disk

  14. david dunger Says:

    We have the same issue, when i put in my 2Gb usb stick into any xp or windows 2003 server I am unable to see the disk # as the usb stick is not visible in diskpart as a disk. it is only visible as a volume. The USB stick is formated as fat or fat32 and can be seen and written to in both xp. windows 2003 and at command prompts, also in disk manager as disk #2. I would suppsoe that it would be seen by diskpart as disk #2.

    The problem is that we can’t do a select disk on a disk that doesn’t appear in diskpart.

    any help would be great.

    Dave

  15. Ken Says:

    One quick note on diskpart. You can do a list disk to see the disks available This will show you the size of the disk as well, so it should be easier to determine which is your usb key. Then use select disk # which is the disk number of your usb key.

    Great article by the way. Very helpfull.
    I am not using the usb key way of doing this, but rather the pxe way. But creating the boot.wim is the same.

    Thanks

    Ken.

  16. Ryan Says:

    Hey Kyle,

    I am stuck right where Alonozo was.
    Diskpart sees the USB drive as a Volume, but not as a disk. I tried to using a lot of the switches, and then doing a rescan, but it still doesn’t recognize the USB key as a disk. I went to Disk Management GUI to look at the USB key. Disk Management does show the USB Drive as “Disk 1″ with drive letter “F”, but Diskpart shows is as “Volume 4″ “ltr F”.

    Do you know a trick to get this USB drive to be recognized as a disk, or can this step of the setup be done another way?

    The USB drive I am using is a Micro Cruzer mini 4 GB.

    Thanks in advance!

    Ryan

  17. Peter Says:

    I think the important bit here is the distinction between USB PEN\KEY and USB hard drives. As far as I know USB PENs are not seen by DiskPart. HP has a tool that will make a PEN drive bootable:

    HPUSBF.EXE is for formatting USB Devices from dos.

    HPUSBFW.EXE is for formatting USB Devices from Windows.

    Search for either on Google and you should be able to find them.

  18. Kirk Davis Says:

    Thanks for a great walk-through; I have my own custom .WIM file, I take it I can just copy this to the USB drive that hosts the WinPE image? Do you have any reccomendations for creating a menu front end, or automating \ scripting the install of the WIM image?

  19. mename Says:

    diskpart is unable to locate my usb stick as a disk, however it pops up fine under volumes.. also the computer I want to boot with the usb stick recognizes the stick just fine during bootup..

    Is there another way to add the MBR on the stick proper?

  20. Danny Zee Says:

    Can you use the usb WinPE as a rootkit discovery tool? The method posted on Microsfts site states a live cd.

  21. Danny Zee Says:

    Simple steps you can take to detect some of today’s ghostware:
    Run “dir /s /b /ah” and “dir /s /b /a-h” inside the potentially infected OS and save the results.
    Boot into a clean CD, run “dir /s /b /ah” and “dir /s /b /a-h” on the same drive, and save the results.
    Run a clean version of WinDiff from the CD on the two sets of results to detect file-hiding ghostware (i.e., invisible inside, but visible from outside). See Hacker Defender ghostware files revealed (highlighted) for an example.
    Note: there will be some false positives. Also, this does not detect stealth software that hides in BIOS, Video card EEPROM, disk bad sectors, Alternate Data Streams, etc.

  22. Carlos Says:

    I know this artical is about USB but could you helpwith this problem. I’ve created a boot CD from the resulting file .iso and it sort of works. It boots into the winPE cd loads the file and the screen changes to vista background then CMD prompt opens and displays
    X:\Windows\System32>Winpeinit and thats it, it never gets past this screen. I checked network traffic and it is sending out DHCP discover packets, If I run NIC boot rom it will connect to a WDS and download winpe from it so the network connection would seem to be OK, whats gone wrong.

  23. tim clark Says:

    So it looks like we have the reoccurring them here of diskpart not seeing the usb device as a disk or not seeing it at all

    I think the issue is that xp / w2k3 dont have the right version of diskpart.exe
    I think from the sceen shots i see we need v6

    I googled to the cows come but cat find it
    does anyone know
    1) if there is a win2k3/xp diskpart v6
    2) a 3rd party app that make usb device boot able with vista/win svr 2008 boot image

  24. Barry Says:

    Hey Kyle, worked a charm, but only in Vista.
    XP, as in all the other ppl’s cases, diskpart wouldn’t see the thumbdrive as a disk.

    But, also, I couldn’t leave the /s switch on the copy command to get the tools to the Windows dir. It kept erroring. Took it out and hey presto it’s working fine.

    That first part, about creating the bootable partition etc on the usbkey is fantastically handy. I think it just helped me with some other stuff! Love your work!!

  25. twindude Says:

    i have the PE disk working but wondering how to add apps to it now? or maybe kick off a shell… like a windows looking sheell i use to use BartPE but booting form a USB is almost impossible.. so i going to use WinPE .. I have it booting to a command prompt and I can look under program files and see my app dirs but the exe will not run. so i’m thinkin that i have to have files in the system32 dir and all… any help would be great

  26. Lars Says:

    I’m a little late to this, but I noticed a bunch of people having issues with diskpart. I personally used a GParted LiveCD (http://gparted.sourceforge.net) for that step. If you think about it in disk formatting/partition terms, all diskpart is doing is wiping out everything on the USB drive, creating a primary partition, marking it as active (aka boot), then formatting the partition. You can do the same exact thing in GParted as long as it detects your USB drive as another disk. Give it a shot & see if it works for you too, worked great for both of my USB drives (one HDD & one Flash).

    Just my two cents :)

  27. Barry Says:

    Oh, and one thing to watch too…don’t format a 4gig USB stick if you’re in a hurry…this takes a while eh?? *sigh*!!

  28. kyle Says:

    @Barry

    very true.. well.. depending on your disk’s speed of course.

    The other alternative is to use the switch /q for a quick format.

    Other useful switches (Barry I figure you know these but for anyone else)
    /fs:ntfs (to force the format to NTFS)
    /c to enable compression
    /v:label to label the volume.

    Cheers
    kyle

  29. Steven Zimmer Says:

    Hi!

    I just did a windows update on my vista home premium and when I rebooted could not get back into windows as the password I use has become invalid. I cannot get into safe mode command prompt cannot repair the settings nor go back to an earlier valid version (all through F8). In other words, I am completely blocked for the moment. Have you ever seen this happen before? Is there anyway around this other than extracting the data from the hard drive and starting all over again?

    Thanks for any words of advice

    Regards

    Steven

  30. Alex Says:

    Hi, do anyone know how to create a winpe bootable with start menu and window explore so i can do some formating when i boot from my USB ?

  31. Jon Says:

    Got stuck at 5… run xcopy “c:\Program Files\Windows AIK\Tools\x86\*.*” mount\ /s
    Any ideas? Newbie

  32. Chris Says:

    @Alex

    Windows PE doesn’t have a standard windows shell, the command prompt is what you’re getting. You can however do most of what you want to from there. There are command line utilities to do everything you’ve listed.

    Not what you wanted I’m sure, but I hope it’s some help.

    Chris

  33. Paul Says:

    Had to restore a failed Dell system via Factory.wim (from D partition), this article saved me a ton of time. Cheers!

  34. Claude Says:

    I have a Toshiba A300. I would like to restore an old Ghost image of this computer but when I boot with the emergency boot disk from Norton/Symantec it says it can’t find any network or the D: drive which came with the Notebook. When I try to build a new emergency boot disk from this disk it says it hasn’t got the drivers for my notebook. Any ideas how I can get to restore my old ghost image to my notebook?

  35. Claude Says:

    Sorry I forgot I an running Vista Business Ultimate on the notebook

  36. DrBob Says:

    I have created a bootable CD that formats the drive and loads in my Wim. It works great when I use it in an internal cd drive on the computer. If I remove the internal drive and replace it with an external drive (so the drive letters stay the same) the CD does not work. It starts to load the WinPE shell correctly but causes the PC to reboot before the format begins.

    Why does the CD work correctly from an internal CDROM but doesn’t work when using an external CDROM?

    Thanks!

  37. Paul L. Says:

    THANKS, I was following Microsoft’s 5105B Course instructions and they do not work for making a bootable CD.

    Your instructions worked perfectly!

    Thanks!!!

  38. Windows 7 PE Bootable DVD/CD - Windows 7 Forums Says:

    [...] [...]

  39. leew Says:

    For those getting stuck on Step 6 – the xcopy command yields an error – “Invalid number of parameters” – This is most likely because you copy and paste the command from the web page. The web page uses smart quotes and the command prompt doesn’t change them – the net effect is that you don’t actually have the command in quotes so the it looks like there are an extra two parameters. To resolve:
    paste the line and delete the quotes and retype them (the LOOK the same, but they are different), or manually type the entire line.

  40. Popeye Says:

    I was hoping for a GUI too. Can’t we have a PE boot disk with a Windows shell? I want to be able to access Windows restore points, Winrescue restore points and maybe run an antivirus scan after booting with the CD. Winrescue XP had the facility for making such a CD, but Winrescue Vista doesn’t.

  41. Creating Bootable Vista / Windows 7 USB Flash Drive « Adrian Francis Weblog Says:

    [...] drive for a Vista and/or Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  42. jlexen Says:

    the clean command doesn’t work. It gives this:
    The selected disk is neccessary to the operation of your computer, and may not be cleaned.

    (and yes, the programmers DID spell necessary wrong XD….)

  43. kyle Says:

    @jlexcen – lucky for you – that it didn’t work. The message means that you have the wrong drive selected – in fact I am looking at that and suggest you have your system drive selected.

    Make sure youhave your USB drive selected and the command will work.

  44. Will Says:

    For all of you having issue with diskpart not seeing the thumbdrives. Only the Vista and Server 2003 diskpart.exe can see it. If you look at the walk-throughs that you see on the web of people doing it its always in vista.

  45. Creating Bootable Vista / Windows 7 USB Flash Drive « pablosu.com Says:

    [...] drive for a Vista and/or Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  46. Tyler Says:

    ——- ATTENTION Diskpart XP users ——-

    Anyone that does not have Vista available to them simply burn a CD version of PE, load it up with USB Thumb connected and once you’re loaded in you can use diskpart on your USB pen from there. Just make sure you select the correct disk when formatting.. as always.

    Is this crazy? Maybe.. does it work? yep.

  47. 10 Tipps fürs Deployment von Windows 7 @ lars-schuh.com Says:

    [...] von Abbildern mithilfe von WinPE-Tools anzubieten hat. Zum Beispiel zeigen die Schritte unter vistapcguy.net/?p=71, wie mit den WinPE-Tools ein bootfähiges Flashlaufwerk und ein Installationsabbild darauf erstellt [...]

  48. Creating A Bootable Windows 7 USB Flash Drive - The Digital Jedi's Words Says:

    [...] USB thumb/pen/flash drive for a Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  49. Kelly Says:

    Quick Question: Why step #11 for USB Boot? It creates an ISO that is stored in the root PE directory.

    The subsequent directions have you copy only the ISO directory contents to the USB Key which doesn’t include the ISO at all. I get making an ISO for a bootable CD, but how is the OSCDIMG utility needed to prep the PE Image for a USB drive?

    Thanks!

  50. Ramandeep Goyal'z » Blog Archive » How To Create Bootable Vista / Windows 7 USB Flash Drive Says:

    [...] drive for a Vista and/or Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  51. firefly2000uk Says:

    Thanks for the guide!

    Can I just point out one issue:

    If you are trying to use “PEIMG” and it fails to load because it is missing you need to use the “DISM” tool.

    simple use DISM in place of PEIMG

    :)

  52. at Kevin’s Blog Says:

    [...] drive for a Vista and/or Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  53. How To Boot From A USB Flash Drive | Dev-Zone.NET Says:

    [...] drive for a Vista and/or Windows 7 installation.  I cobbled together the following from VistaPCGuy and another source I don’t remember right [...]

  54. scorpcrite Says:

    If anybody having problems USB seem as a removable disk and you can do partition. dont bother skip that command and continue as removeable disk itself is a partition.

  55. Steve Luke Says:

    I ran into a bunch of trouble trying this on Win 7:
    1. There is no peimg command

    2. I tried firefly’s suggestion of using DISM instead, but DISM has no /list, /install, or /prep options, so you can’t just use DISM in place of peimg as suggested. I also couldn’t find any commands in the DISM /? which could be substituted. So I skipped any step with peimg in it.

    3. The path to etfsboot is incorrect, it should be “C:\Program Files\Windows AIK\Tools\PETools\x86\boot\etfsboot.exe”

    The result was that the created USB disk was bootable and I could run things like imagex, but other applications I copied (like GHOST) would not run.

  56. PNA Says:

    2012: If your main goal is to maintain, troubleshoot, repair or restore your existing system you may do better by creating the various Recovery Disks as suggested by the manufacture and/or using the Windows option to create a bootable Repair Disk.

    Most of these options use Windows AIK to make a Windows RE (Recovery Environment)disc or a Windows PE (Preinstallation Environment) disc and offer a Command Prompt and Windows DOS along with system specific tools that you just can’t get anywhere else.

    As you become more skilled you can use and expand on these WAIK images and transfer them from CD/DVD to USB devices.

    I also suggest using ROBOCOPY (part of Windows DOS since Vista) in multi-thread mode for copying entire directory structures. I used my Repair Disk to ROBOCOPY my Vaio Laptop’s entire Recovery partition to a USB drive very quickly. About 8 times faster than XCOPY!

    XCOPY and older copy commands copy 1 file at a time sequentially. ROBOCOPY can copy multiple files at the same time making it especially useful for copying to USB drives.

    In short, this gave me a 64 bit Windows 7 AIK environment with all the drivers that my system needed without me having to have very much technical knowledge to get me started. I also got a 32 bit Vista AIK from my other Vaio Laptop.

    Hope this helps someone get from A to Z just a little faster. :)

Leave a Comment

  • Locations of visitors to this page