Sunday, November 01, 2009

Sexy USB Boots (Win PE style)

sexy boots“Tiffany’s New Boots” flickr cc image by akseez

Due to a generous birthday-fun contribution from my little bro I recently picked up a Patriot Xporter XT Boost 16GB flash drive stick for my personal use.  I’ve got a number of 512 MB ones scattered around, as well as my dependable 2 GB one, but after the latest round of family IT support service calls, I really wanted one with enough room that I could store all my portable utilities on; and still have enough room for a few ISO files.  More importantly I wanted a fairly-fast USB stick I could configure to use as a Win PE boot device.

Not that I have anything against bootable CD/DVD media.  It certainly has its place, but having a Win PE boot stick is just so much more sexy.  Not only is it wicked-fast for off-line booting a Windows system for response and support, but it also allows me to save log data or recovered files directly to, rather than try to offload them to a network share, the Net, or a non-booting USB storage device.

I’ve already covered this ground before at work with my current “for work purposes only” 8 GB USB stick.  For that I used PurvianceCS’s post on how to Create a Bootable VistaPE USB Hard Drive or Flashdrive.  Because this was based on my earlier VistaPE building work, it was a natural progression and worked flawlessly.  It does use GRUB as the bootloader for the Win PE WIM handoff.  That’s no problem and GRUB has an amazing amount of flexibility for multi-booting USB devices. However, to be honest, I never use any of the additional boot options it provides.  I just boot to the Win PE WIM file and continue on.

I had in the past posted a few link round-ups to various ways and tools and techniques for making USB devices bootable.

They all are good and provide lots of great background but I really wanted a solution that was dead-fast, simple, and rock-solid for setting up a (supported) USB storage device to be used as a boot device for Win PE builds.

This was particularly important for me as well since in our IT shop we now have over twenty-five portable Western Digital external hard drives that I keep updated with ImageX-based WIM images of our various hardware systems.  When I hand them out on projects, a folder goes with them containing CD-ROM’s of my custom Win PE boot disk along with a Clonezilla disk as well (images for those are on the drives as well).  Wouldn’t it be nice if the CD drive was funky or problematic to allow the techs to boot directly from the same device the images were stored on? Yep.

So after some brief work and experimentation, I found the following technique worked “bestest and fastest” for not only making my personal USB device quickly bootable, but all these external USB hard drives as well.  And all done with my own hands!

The Technique

This assumes a few things first, so let’s get those out of the way.

  1. There is nothing now on the drive you want to save (or you have backed it up already).
  2. The drive is (or will be) NTFS formatted.  (I’m not sure this is a requirement but it seems to improve speed.)
  3. The USB storage device supports USB booting (not all do).
  4. You are reasonably comfortable with CLI work, including DISKPART.
  5. You already know that to use the thing, you may have to set your BIOS to the “boot from USB” option (or select it in a one-time boot option at BIOS startup…).

I actually found this easiest to do while running under a Win PE 2.0 (Vista) or Win PE 3.0 (Win7) session, though you can do it from an administrator-elevated command prompt session under Vista or Windows 7 as well.

Note: Please read this carefully, review the provided supporting cross-linked posts, and make sure you understand what you are doing in advance. Also be sure you have all the required ingredients ready and on the counter-top before you start cooking!  If you don’t or aren’t sure what you are doing, you run the risk of nuking your system, possibly un-recoverably!  Your Poodles might turn pink and your beloved family hamsters might escape in the night.

Format the Drive

  1. Pop in your USB storage device.
  2. Open a command session (CMD.exe).  If not using a Win PE session, go to “Start” –> “Programs” –> “Accessories” –> “Command Prompt” and right-click and select “Run as administrator”
  3. Type DISKPART
  4. Let’s make sure you correctly identify which drive number your USB device is listed as!
  5. Type LIST DISK
  6. All storage devices will be listed.  You should be able to tell which yours is by the size. In most cases, mine shows up as “1” with my local hard-drive listed as “0”.  Yours may vary so check carefully and use your drive number accordingly in the next steps!
  7. Let’s clean up the drive first to avoid any issues.  Note: data loss will occur on the device at this point!
  8. Type SELECT DISK 1   (this makes the USB drive the focus of the actions to follow)
  9. Type CLEAN       (This deletes the MBR section of the storage device)
  10. Type CREATE PARTITION PRIMARY     (This creates a fresh, single partition out of the available space)
  11. Type ACTIVE      (This makes firmware see the partition as a “system” partition)
  12. Type ASSIGN     (This assigns the next available drive letter to the device)
  13. Type LIST VOLUME   (Take a look and make note of what drive letter got assigned to the USB device)
  14. Type EXIT

Now type the following to actually format the USB device.  Make sure your drive letter is correct!

Format <drive letter>: /fs:ntfs /q /y     (where <drive letter>: equals the USB device letter found from #13 above…in my case it was e:  )

This formats the drive letter listed, with the NTFS file system, quick, without requiring confirmation checks.

And yes…I know you can also do a format from within DISKPART.  I just like doing it this way.  It’s a personal preference thing….

Pull on your USB Boots

Now we need to do some mojo-jojo to make the USB storage device bootable.  To do so we need the BOOTSECT.EXE utility.  It is on Vista and Windows 7 setup disks as well as within the Windows AIK kits for both.

I suppose you can find it available with Google as well, but I like to have the real thing from source.

The simplest way I can recommend getting BOOTSECT.EXE is to download and install one of the following WAIK’s from Microsoft.  In fact, if you are bothering to read this post, and are a WinPE builder, I’d be surprised if you didn’t already have one of these installed.

If you have already installed it, you can find the file in either of the following locations (depending on what flavor you want).

C:\Program Files\Windows AIK\Tools\PETools\x86\bootsect.exe
C:\Program Files\Windows AIK\Tools\PETools\amd64\bootsect.exe

If you do, say, have a hand-me-down WinPE boot CD/DVD but don’t want to install the WAIK to get the tool, an alternative is to extract it from the downloaded WAIK ISO file.

You can use various freeware utilities (SlySoft Virtual CloneDrive, or Pismo File Mount, or ImDisk) to mount the ISO as a virtual folder/drive.

Then follow the tips in this handy NirSoft Blog post -- How to extract missing system files from the DVD of Windows 7/Vista -- and browse to the following location in the WAIK ISO:

\KB3AIK_EN.iso\WinPE.cab\F1_WINPE.WIM\1\Windows\System32\bootsect.exe

…and extract the file.

Mkay?

Now, in your command-line session browse over to the directory location where you have placed the BOOTSECT.EXE file and execute it with the following command:

BOOTSECT /NT60 <usb drive letter>    (Where <usb drive letter> equals your USB device)

again, in my case I would be typing BOOTSECT /NT60 E:

If all goes well you will get a message about the process updating correctly.

Type EXIT to close out the command window.

Need more info on BootSect magic?

Add your Win PE boot file.

Last step is to copy over the required files from your pre-build WinPE CD/DVD disk.

In my case I was using the Win PE 2.0/3.0 files from these previous GSD projects:

Using your favorite Windows file manager program (with options enabled to see system/hidden files) pop your Win PE 2.0 or 3.0 boot disk into your system and then copy the following files/folders over to the root of your USB device:

  • BOOT (folder & contents)
  • EFI (folder & contents)
  • SOURCES (folder & contents)
  • bootmgr (file)

At this point, you can also copy over any additional folders, (portable) programs, etc. that you might want to have available from the USB device when you boot into the Win PE environment.

You should now be able to just pop the device into a system that supports USB device booting, and selecting that option (if not already configured in the BIOS) boot the system to test.

Has worked like a charm on my devices and systems using this technique.  Sexy USB drive booting goodness, much faster and more convenient for system support than optical media based Win PE boot build can provide!

More Stuff

It seems like a lot of stuff to do to make your USB device bootable, but believe me. After making your tenth or eleventh USB storage device Win PE boot supported, you can do it in your sleep.  For me it now takes less than three or four minutes per device now to run down the steps.  Seriously!

One of the cool things I have found is that by setting up your USB storage device this way, just about any WIM PE based boot.wim file will be supported.

So what I did was create another folder SOURCES-EXTRAS and dumped other boot.wim file builds in it renamed with a descriptive hint.  Then when I want to boot using a particular Win PE build, I just have to first rename my primary WIM file in the SOURCES folder to something like boot.wim.x and then copy the alternative WIM out of by backup SOURCES-EXTRA folder into SOURCES folder, then rename it to boot.wim.  This gives me greater flexiblity when I need a particular Win PE build.  Like not using my primary one with the sexy Laura Croft background wallpaper when I am at the in-laws…just for example….but the one with a more appropriate wallpaper for that particular audience.

Other boot.wim files I have stored are as follows:

In all these cases, generally I just need to copy the boot.wim file out of the SOURCES folder and (after renaming it) drop it into the SOURCES-EXTRA folder.  Sometimes these do carry extra folders on the root, so take a look around and make sure you get any supporting folders you might need for them to work properly.  Generally those will go under the USB device root.

I also make sure I have a copy of Imagex.exe taken from the WAIK was well. Note that the Win PE 3.0 IMAGEX version is more advanced (link to nice posts from 4sysops blog) than the Win PE 2.0 version.  While I like the added features in the PE 3.0 one, I still prefer using the PE 2.0 for image capture/application at work and home (for now).

Odds-n-Ends

Here are some more (mostly) related posts that might be of interest to you as you expand your USB WinPE booting device.

Now go and enjoy those sexy boots!

--Claus V.

1 comment:

SS said...

Have a look at RMPrepUSB for a USB drive preparation utility. www.rmprepusb.com