📜 ⬆️ ⬇️

Install Microsoft Hyper-V Server 2008 R2 on Flash-drive


When VMware released a free version of their hypervisor called ESXi - after some time diskless servers appeared on the market, loading the hypervisor itself from a small flash card. The virtual machine files themselves are stored on external storage systems. This reduces the cost of equipment, as there is no need to equip the servers with their own hard drives and RAID controllers. Microsoft released their version of the hypervisor, called Hyper-V, including it in Windows Server 2008. Following this, a free product called Hyper-V Server 2008 was released, which is an extremely curtailed version of Windows Server 2008 Server Core, with The only role is Hyper-V. Unlike VMware products, Hyper-V does not require the purchase of any licenses for individual “features” of the hypervisor, and it may be preferable if only the MS Windows OS will be used as guest OS. Hyper-V Server 2008 R2 uses a new hypervisor, Hyper-V 2.0, with support for its new features — in particular, Live Migration. Also, Hyper-V Server 2008 R2 can work on more powerful systems (with a larger number of processors and RAM) than the previous version, and can work as part of a Failover cluster. Nevertheless, not everyone knows that Hyper-V Server 2008 R2 can also boot from a flash drive, in the same way, by the way, like Windows Server 2008 R2 and Windows 7. In this article I will tell you how to make Hyper-V Server 2008 R2 Bootable Flash Drive.

What is it for?


As you know, most often at computers hard drives fail. Relatively recently, flash-based hard drives have appeared on the market. They differ from standard disks by much greater reliability and speed, since they do not contain moving parts. Unfortunately, their main disadvantage is the high cost: SSD disks usually cost several times more than standard hard disks of the same size.
Flash drives, however, are much cheaper, and may well be held under the article "consumables" along with paper and cartridges for printers. In addition, it is much easier and faster to prepare a lot of bootable flash drives in the way described in the article than to clone hard drives, and therefore we get a more scalable solution: you can prepare several dozens of servers in one day, which you can only configure later (which can also be automated, using scripts). In addition to scalability, fault tolerance also increases: when a server fails, it will be enough to simply rearrange the flash drive to a new server, rather than restore it from backup copies.

So what do we need?


From the software we need:

From the "iron":

')

Step 1: Create the VHD


The VHD (Virtual Hard Disk) file format was originally developed by Connectix, subsequently purchased by Microsoft. VHD format was used for virtual hard disk files in Microsoft VirtualPC and Virtual Server products, and then Hyper-V. The VHD format is open, and there is software from other developers that uses this format. In Windows 7 and Windows Server 2008 R2, VHD format files are supported at the OS level, and can be mounted as a disk in the system. Moreover, the OS can even be installed and booted from VHD. In our case, we will create a VHD file on our flash drive, then write the Hyper-V Server 2008 R2 system files there and make it so that the OS can be loaded from this VHD.
So, insert our flash drive into a computer with Windows 7 and run the “Computer Management” snap-in (compmgmt.msc). Go to Disk Management and select "Create VHD". Choose where our image file will be stored (any temporary folder on the hard disk - you can do it right away on the flash drive, but it will be faster), set the size - 25% of free space should remain on the flash drive, in the case of 16 -gigabyte flash drive will make 12 GB, and click Create. The process of creating a VHD will take some time, so you can safely go to drink something refreshing or intoxicating and do boxing by correspondence on your favorite forum, as without it ...


After we drank coffee - you can look at the automatically mounted new disk, initialize it and create a single partition on it, formatting it in NTFS.

Step 2. Unpack the installation image on the VHD


Now we need to unpack the installation image of Hyper-V Server on the created disk. We will need the Hyper-V Server 2008 R2 installation disk or its ISO image. More specifically, we need the install.wim file stored in the SOURCES folder on the installation disk (or ISO image). If we have a downloaded ISO image, it must either be burned onto a DVD-ROM, or unpacked onto a hard disk, or mounted using any suitable program (Alcohol 120%, Daemon Tools, UltraISO, Nero). The WIM image is unpacked using the ImageX utility included with the WAIK. We execute the following command (meaning that the ISO image is mounted as an E: drive, and the VHD is like an F: drive):
C: \ Program Files \ Windows AIK \ tools \ x86 \ imagex / apply E: \ SOURCES \ install.wim 1 F: \
It is necessary to take into account that for successful command execution the console must be started with administrator privileges (Run as Administrator). This process will again take some time, and you can still go to smoke / read your favorite forum / drink coffee / etc.


Step 3. Preparing the flash drive


So, we have prepared our VHD-image, and now we need to copy it to a flash drive and make it so that it can load the OS.

Format the flash drive and copy the VHD file

To begin with, oddly enough, we need to connect our flash drive to the computer on which we created the VHD. The flash drive must be formatted in the NTFS file system (previously, of course, copying all the files you need from it, if any). Before copying VHD you need to unmount it - otherwise the system will not allow copying it to a flash drive. Go to the Computer Management console, right-click on the mounted VHD disk and execute Detach VHD. Now copy the newly created VHD file to the root directory of the flash drive. I hope this step is quite simple and does not need additional explanations.

Create a boot sector

We copied the VHD file, but now we need to make sure that the server can load the OS from our flash drive. First you need to create a boot sector on it. This is done by the bootsect utility, which is also a part of the WAIK (again, administrative privileges will be needed, D: - flash drive):
C: \ Program Files \ Windows AIK \ tools \ PETools \ x86 \ bootsect / nt60 D: / force / mbr

Create a BCD repository (that is, the boot loader itself)

Now it is necessary to indicate to the loader that it is necessary to boot the OS from our VHD. To do this, a so-called BCD (Boot Configuration Data) storage is created on the flash drive. This is done with the help of the BCDboot utility that is included with Windows 7. First, you need to mount a VHD file on the flash drive in the system. Go to the Computer Management - Storage - Disk Management and do Attach VHD, selecting the VHD already from the flash drive. After that we give the command (in the same way, with administrator privileges, D: - flash drive, F: - mounted VHD):
bcdboot F: \ WINDOWS / s D:
Now the flash drive is almost ready to work. It remains to make only one final touch ...


Step 4. Disable the paging file

As you know, Microsoft Windows operating systems use so-called paging files (they are also swap files or paging files). By default, they are stored on the boot partition. Unfortunately, the paging files are characterized by a fairly frequent recording, and this can significantly reduce the service life of the flash drive. Therefore, you must first disable the use of paging files in the system. The easiest way to do this is by using the registry editor. Run the registry editor (regedit) and open the registry hive from the system installed on the VHD. Select HKEY_LOCAL_MACHINE, do the File - Load Hive and select the file (remember that F: is the mounted VHD) F: \ Windows \ system32 \ config \ system. At the request of the name - we give some type name HVTemp. Then we go to the HKLM / HVTemp / ControlSet001 \ Control \ Session Manager \ Memory Management branch and delete the ExistingPageFiles parameter.
Now you can safely unload the registry hive (select HKLM / HVTemp, then File - Unload Hive), unmount the VHD (Computer Management - Storage - Disk Management, Detach VHD), unmount the flash drive and plug it into the server.


Step 5: Finally, boot up!

Well ... The result of our ordeals was a flash drive, with the Microsoft Hyper-V Server 2008 R2 hypervisor installed on it. Now you can simply insert it into the server and boot from it. But before that - you need to make sure that the server meets the requirements for running Hyper-V and is configured to boot from a USB device. These requirements are as follows:

Before booting the OS from the flash drive, you must go into the BIOS Setup on the server and make sure that:

Now you can boot, configure the system, connect the LUNs of the external storage system (and thus get a completely diskless server) and create virtual machines.
Finally, a small recommendation: it is better to hide the bootable flash drive in some way inside the server so that it does not stick out of the case - because it can be accidentally touched, broken or pulled out. Some servers are equipped with a card reader (Card Reader) - this may be generally the ideal solution: it is almost impossible to accidentally pull out an SD card, since it only protrudes outside by one millimeter. Preparing an SD / MMC card is technically no different from a regular USB flash drive, and all the steps are the same as described above. In addition, some servers (in particular, HP in their blade-servers) have internal USB plugs. They are located on the motherboard inside the case and allow you to connect standard USB-drives.


And now - the same thing, only easier!


And now, suddenly, I will please you: all that I wrote in the article above can be not done. Someone Paul Despe created the BootFromUSB utility (http://code.msdn.microsoft.com/BootHVSR2FromUSB), with which you can create a bootable flash drive in a couple of mouse clicks. The utility window looks quite simple:


To use it to create a bootable flash drive - you need to do the following steps:
  1. Install WAIK (where to get it - see the beginning of the article)
  2. Insert the installation disk or mount an ISO image in the system or unpack the Microsoft Hyper-V Server 2008 R2 ISO image (again, see above)
  3. Connect a flash drive (USB flash drive or memory card)
  4. Run the utility as an administrator (Run as Administrator)
  5. Select the flash drive as the target USB Flash Drive (Caution! It will be formatted during operation!)
  6. Click Create Blank VHD and select a temporary folder for the VHD file on the hard disk of your computer
  7. Specify the path to the Install.wim file from the Microsoft Hyper-V Server 2008 R2 distribution
  8. Press Start and go to drink coffee / tea / beer. Somewhere in half an hour the flash drive is ready.


Conclusion


Well, actually, that's all. Hope this article has helped you. I am pleased to answer questions in the comments. Thanks for attention!

The original article was published in the journal "System Administrator" â„– 07/08 for 2010.

Source: https://habr.com/ru/post/103243/


All Articles