Welcome to TechNet Blogs Sign in | Join | Help

Fermin Sanchez Central

Tools and stuff I come across during my work as a consultant for Microsoft Switzerland.
How to create the ultimate USB multi boot disk

Since I'm preparing myself for the new Windows 7 and Windows Server 2008 R2 operating systems, I tend to download new builds fairly often and was looking for a quick way to install an operating system on a physical machine without burning DVDs all the time. The obvious answer: I created my own USB boot key that lets me boot multiple operating systems.

What do you need?

  • A "Technician PC" to create the USB key – I did it on a workstation running Windows 7 build 7000, but Vista (and possibly XP? Not tested, though) will also do.
  • The Windows Advanced Installation Kit (WAIK). You can get it from various sources like Technet or from here.
  • A USB key. I'm creating my "monster WIM file" as we speak, and it's already 4.3 GB. You should get an 8 GB (or better) key that's fairly new (for read/write speed).
  • The sources. In other words, you need the x:\sources\install.wim (x: being your CD drive) file of the operating systems you'd like to install.


Step 1: Preparing the USB key

Since the WIM file I'm creating (see Step 2) will be larger than 4 GB, the USB stick needs to be formatted with NTFS. In a command prompt with administrative rights, do the following ("clean" will permanently erase the contents of your USB key!!):

diskpart
list disk
select disk 1
clean
create partition primary
select partition 1
active
format fs=ntfs quick
assign
exit

The above assumes that the "list disk" command showed you two disks, "Disk 0" being your internal hard disk and "Disk 1" being the USB stick. Your system might be different. "clean" will permanently erase the contents of your USB key!! Ony my system, the "assign" command put my USB key on drive H:, this could also be different on yours.

Next, copy the contents for example of a Vista Windows 7 (*) CD to your USB key:

xcopy f:\*.* /s /e /f h:\

Your USB key is now ready to go.
(*) = I found Windows 7 to work best for me. Just use Beta 1 or, when available, RC.


Step 2: Creating the "Monster WIM"

The WIM format introduced with Windows Vista is basically a container for one or more OS images. You can have a look into such a container by starting the WAIK command prompt (see your Windows start menu after installing WAIK) and entering the command "imagex.exe /info x:\sources\install.wim" (assuming x: is your DVD drive). The output will look something like this (some output snipped):

C:\Windows\system32>imagex.exe /info f:\sources\install.wim

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.


WIM Information:
----------------
GUID:     {a99a2697-00aa-47fb-a514-86e22cc1a7a6}
Image Count:     6
Compression:     LZX
Part Number:     1/1
Attributes:    0xc
        Integrity info
        Relative path junction

Available Image Choices:
------------------------
<WIM>
<TOTALBYTES>2643418299</TOTALBYTES>
<IMAGE INDEX="1">
(snip)
<NAME>Windows 7 SERVERSTANDARD</NAME>
<DESCRIPTION>Windows 7 SERVERSTANDARD</DESCRIPTION>
<FLAGS>ServerStandard</FLAGS>
<HARDLINKBYTES>3637973169</HARDLINKBYTES>
<DISPLAYNAME>Windows Server 2008 R2 Standard (Full Installation)</DISPLAYNAME>
(snip)
</IMAGE>
<IMAGE INDEX="2">
(snip)
<NAME>Windows 7 SERVERSTANDARDCORE</NAME>
<DESCRIPTION>Windows 7 SERVERSTANDARDCORE</DESCRIPTION>
<FLAGS>ServerStandardCore</FLAGS>
<HARDLINKBYTES>995178928</HARDLINKBYTES>
<DISPLAYNAME>Windows Server 2008 R2 Standard (Server Core Installation)</DISPLAYNAME>
</IMAGE>

As you can see in the partial output above, the WIM contains 6 images; I've included the more important parts of the first two images. Creating the actual WIM is now straightforward enough:

imagex.exe /export f:\sources\install.wim 1 d:\temp\install.wim 1 "Windows Server 2008 R2 Standard (FULL)"
imagex.exe /export f:\sources\install.wim 1 d:\temp\install.wim 2 "Windows Server 2008 R2 Standard (CORE)"

Now insert the next DVD, say with Windows Server 2008 x64, and repeat the process (run "imagex.exe /info …" to see which images to get):

imagex.exe /export f:\sources\install.wim 1 d:\temp\install.wim 2 "Windows Server 2008 Enterprise x64 (FULL)"
imagex.exe /export f:\sources\install.wim 1 d:\temp\install.wim 5 "Windows Server 2008 Enterprise x64 (CORE)"


You don't have to worry about numbering in your newly created WIM file; imagex.exe will assign them automatically in ascending order. If you want to get rid of an image in your WIM, use:

imagex.exe /delete d:\temp\install.wim 1


Step 3: Copying the new WIM file to the USB key

All that remains to do is replacing the "install.wim" on your USB key with your customized one:

copy d:\temp\install.wim h:\sources

Select "Yes" if prompted to overwrite the existing install.wim.

Conclusion

That's it, you should now be able to boot from the USB key (provided your computer's BIOS supports this and it has been enabled) and start installing away. To dramatically increase performance during the export of the images, either mount the source OS DVDs using a .ISO mount tool or copy the install.wim to your local hard disk. You may also want to experiment with different USB key drives to find one that is fast enough for your needs.

iscsicpl.exe included in R2 Core/Hyper-V Server Beta!!
One of the major pains seems to be going away in R2: iSCSIcpl.exe is included in R2 Core and R2 Hyper-V Server! That means no more "iscsicli AddTargetPortal 192.168.1.1 3260 * 1 * * * * * * * * * *" and other stuff that has you staring crosseyed at your screen... Of course there is no guarantee that it will still be in later versions or RTM.
Remote Volume GUIDs driving you crazy?

I was maybe half an hour away from giving up on my Hyper-V Server Core box and doing a "Full" install. The solution, once you know it, is simple... the problem was there seemed no way to reattach a previously created virtual machine. I hadn't done an export, so "import" wasn't an option. Usually, what you do in this situation is you create a new virtual machine and attach the old VHD file. Since I'm planning to use Failover Clustering, the VHD files reside on a iSCSI SAN and instead of drive letters, I'm using Volume GUIDs.

Almost all has to be done remotely, because the Hyper-V box is a Core machine.

First, how do I get the GUID of the volume where my VHD file is stored? On the Server Core box, open a command line and type "mountvol". You will see something like this:

It's obviously neither "C:" nor "D:"... so which is it? The most intuitive thing would be to copy/paste the path(s) and prepend them with "dir ", then go through them in order. However:

No such luck. Try the same, but add an additional backslash at the end this time:

There you go. Now the process of remotely attaching the VHD file in Hyper-V Manager is straightforward:

What still won't work is using the remote tools to browse a path that contains a Volume GUID:

If you want to remotely browse remote volumes, you should clear the path and then click browse:

Once the disk has been attached, you can inspect it, even though it uses a Volume GUID instead of a drive letter:

In conclusion, one more "\" can sometimes be all the difference in the world...

How to patch Windows Server 2008 Core using WSUS

Using the script from here, I can patch my Core box. I've added some code (bold) so I don't have to look up the return codes (which can be found here).

Dim myResultCode(5)
myResultCode(0) = "Not started"
myResultCode(1) = "In Progress"
myResultCode(2) = "Succeeded"
myResultCode(3) = "Succeeded, but with errors"
myResultCode(4) = "Failed"
myResultCode(5) = "Aborted"

Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()

WScript.Echo "Searching for updates..." & vbCRLF

Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")


WScript.Echo "List of applicable items on the machine:"

For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> " & update.Title
Next

If searchResult.Updates.Count = 0 Then
 WScript.Echo "There are no applicable updates."
 WScript.Quit
End If

WScript.Echo vbCRLF & "Creating collection of updates to download:"

Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

For I = 0 to searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> adding: " & update.Title
    updatesToDownload.Add(update)
Next

WScript.Echo vbCRLF & "Downloading updates..."

Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()

WScript.Echo  vbCRLF & "List of downloaded updates:"

For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    If update.IsDownloaded Then
       WScript.Echo I + 1 & "> " & update.Title
    End If
Next

Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

WScript.Echo  vbCRLF & _
"Creating collection of downloaded updates to install:"

For I = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(I)
    If update.IsDownloaded = true Then
       WScript.Echo I + 1 & "> adding:  " & update.Title
       updatesToInstall.Add(update) 
    End If
Next

WScript.Echo  vbCRLF & "Would you like to install updates now? (Y/N)"
strInput = WScript.StdIn.Readline
WScript.Echo

If (strInput = "N" or strInput = "n") Then
 WScript.Quit
ElseIf (strInput = "Y" or strInput = "y") Then
 WScript.Echo "Installing updates..."
 Set installer = updateSession.CreateUpdateInstaller()
 installer.Updates = updatesToInstall
 Set installationResult = installer.Install()
 
 'Output results of install
 RetCode = installationResult.ResultCode
 WScript.Echo "Installation Result: " & _
 RetCode & " (" & myResultCode(RetCode) & ")"
 WScript.Echo "Reboot Required: " & _
 installationResult.RebootRequired & vbCRLF
 WScript.Echo "Listing of updates installed " & _
  "and individual installation results:"
 
 For I = 0 to updatesToInstall.Count - 1
  RetCode = installationResult.GetUpdateResult(i).ResultCode
  WScript.Echo I + 1 & "> " & _
  updatesToInstall.Item(i).Title & _
  ": " & RetCode & " (" & myResultCode(RetCode ) & ")"  
 Next

End If

Copy the content, save it to "c:\tools\wu.vbs" on your core box and run it: "cscript c:\tools\wu.vbs":

 


 

Hello world
This is just the kick-off entry to my blog. Don't expect daily updates ...
Page view tracker