A Portable Hypervisor: Part Three

Booting into Hyper-V R2 not exciting enough for you? How about booting it from a USB drive?

This third and final part of the portable hypervisor series finds us ready to prepare the USB Flash Drive (UFD) and boot up into Hyper-V R2. It’s an exciting procedure developed by Microsoft for its OEMs but if you have the right tools, you can do it too. Once complete, you’ll have a completely portable Microsoft-flavored hypervisor.

The only limitations to this technology are that the system must meet the minimum requirements for running Hyper-V and the system must be able to boot from a UFD. The specific hardware requirements are in Part Two of this series.

UFD Setup

The third step in this process is to prepare the UFD by formatting it as a single volume. The virtual hard image, if you recall from Part Two, is 12GB in size. The DiskPart utility is used for proper formatting of the UFD using the NT filesystem (NTFS). Hyper-V will only install and run on an NTFS volume.

  1. Attach the UFD to your technician computer.
  2. Open a Command Prompt, Start->Run->CMD->OK.
  3. Use DiskPart to look at the UFD’s details, C:\> DISKPART.
  4. List all disks attached to the system, DISKPART> LIST DISK.

    You should see a table similar to the following:

    Disk ### Status Size Free Dyn Gpt
    Disk 0 Online 149 GB 0 B    
    Disk 1 Online 15GB 0B    

    The UFD is the one shown as 15GB (Disk 1).

  5. Select the UFD, DISKPART> SELECT DISK 1
  6. Delete partitions from the UFD, DISKPART> CLEAN.
  7. Create the partition, DISKPART> CREATE PARTITION PRIMARY
  8. Select the new partition, DISKPART> SELECT PARTITION 1.
  9. Set the partition as active, DISKPART> ACTIVE.
  10. Format the UFD with NTFS, DISKPART> FORMAT QUICK FS=NTFS.
  11. Assign a Drive letter to the newly formatted UFD, DISKPART> ASSIGN LETTER=Z.
  12. Exit DiskPart, DISKPART> EXIT.

The UFD is now set to Drive Z: and is formatted as a single volume.

Virtual Disk Setup

In this step, you’ll copy the virtual hard disk file to the UFD and setup the Master Boot Record (MBR).

  1. Open a Command Prompt, Start->Run->CMD->OK.
  2. Copy the virtual hard disk file to the UFD, C:\> COPY C:\HVVHD\HYPER-V.VHD Z:.
  3. Select your specific hypervisor system architecture, C:\> CD /D “C:\PROGRAM FILES\WINDOWS OPK\TOOLS\PETools\”
    Where architecture is x86, AMD64 or IA64.
  4. Create the new MBR on the UFD, C:\> BOOTSECT /NT60 Z: /FORCE /MBR
  5. Use DiskPart to attach the virtual hard disk to the technician computer, C:\> DISKPART.
  6. Select the virtual disk file, DISKPART> SELECT VDISK FILE=Z:\HYPER-V.VHD.
  7. Attach the virtual disk, DISKPART> ATTACH VDISK.
  8. Exit, DISKPART> EXIT.
  9. Using the BCDboot tool to create the boot environment files on the UFD,C:\> BCDBOOT R:\WINDOWS /S Z:.
    R: is referring to the drive letter assigned in the IMAGEX step in Part Two of this article.

The UFD is now ready and bootable as a Hyper-V Server but before you run away, you might want to consider disabling paging as described in the next section. If you decide not to disable paging for the UFD, skip to the section, UFD Detach and Boot.

Paging Configuration

Microsoft recommends that you disable paging to prolong the life of the UFD. In the following steps, you are editing the registry hive on the UFD that Hyper-V will use. Take extreme caution to enter the commands exactly as shown here. Issue these commands from a command prompt (Start->Run->CMD->OK).

Note: These commands are all single line. They wrap here because of formatting so if you copy and paste from this article, be sure to edit in Notepad first to create the commands as a single line.

The steps shown below are:

  1. Loading the registry hive into a temporary hive for editing,
  2. Clearing the paging file value in the registry,
  3. Deleting the page file entry and
  4. Unloading the temporary registry hive.
  • C:\> REG LOAD HKLM\HyperVTemp R:\WINDOWS\SYSTEM32\CONFIG\SYSTEM
  • C:\> REG ADD “HKLM\HyperVTemp\ControlSet001\Control\Session Manager\Memory Management” /V PagingFiles /T REG_MULTI_SZ /D “” /F
  • C:\> REG DELETE “HKLM\HyperVTemp\ControlSet001\Control\Session Manager\Memory Management” /V ExistingPageFiles /F
  • C:\> REG UNLOAD HKLM\HyperVTemp

UFD Detach and Boot

To detach the UFD from the technician computer, open a command prompt (Start->Run->CMD->OK) and execute the following commands.

  1. Start DiskPart, C:\> DISKPART.
  2. Select the UFD, DISKPART> SELECT VDISK FILE=Z:\HYPER-V.VHD.
  3. Detach the UFD, DISKPART> DETACH VDISK.
  4. Exit DiskPart, DISKPART> EXIT.

Insert your UFD into your system, noting the non-removable UFD setup instructions from Part Two of this article. The UFD will not boot from a standard external USB port. You must edit your BIOS settings to allow booting to the UFD and the UFD should be recognized by the system as another hard disk since Hyper-V will not boot from removable media.

There you have it—your very own UFD bootable Hyper-V server system. Once booted, your system is ready for virtual machines. If you want some great insight into installing Linux virtual machines into Hyper-V R2, check out Jason Perlow’s Geek Sheet: Virtualizing Free Linux Distributions in Windows Server 2008 R2. Thanks to Jeff Woolsey and the Microsoft Corporation for providing the Hyper-V R2 software and documentation used to create this article.

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62