Starting Windows Server 2012R2 from a VHDX file from a USB drive via UEFI

I decided to make a disk array on the Intel Atom D410PT platform. This is a motherboard with passive cooling of the processor, two memory slots (maximum 4Gb), one PCI slot (which I used for the SATA SiliconImage 3512 controller - 2x1.5Gb / s), 2 SATA (3.0Gb / s) connectors, LAN 100mb / s , and numerous USB 2.0 ports (including on the motherboard itself).
The board itself fits easily into the NaviPower PIX-1001 230W chassis. I posted a full description of my actions with iron on my website .

Accordingly, since Since it was decided to use 4 disks to create a RAID5 array, a logical decision emerged to transfer the operating system to an external USB drive (in my case, a Seagate Freeagent GoFlex USB HDD). Since installing and configuring the system from scratch is often a long and painstaking task, I decided that the system would lie on an external drive in a VHDX container, and since the motherboard supports UEFI, the download should go accordingly using UEFI. The main problem was that there was no clear instruction on the Internet how to do this. All information is very fragmented, and only parts of the solution to this problem are described.

I decided to do this: first install the system as usual on a SATA drive, and then transfer it to a VHDX container and then to an external USB HDD.
I’ll skip the installation of the system, because this is a trivial operation that does not require special knowledge (the only thing is that if you want to install the system on a GPT disk, you will need to play with diskpart before installation).
An important addition: before transferring the system to an external drive, it is imperative to disable the page file and the hibernation system!
Accordingly, we install system, program updates, make settings.
Next, you need to transfer the system to a VHDX container. For this, the Disk2VHD 2.01 program was downloaded. Its interface is primitive. You just need to select the drive to transfer, the VHDX file and start the process.

After that, on a working system (it is possible on Windows 7 x64, but then there will be problems with VHDX. It is better to take Windows Server 2012 or Windows 8 x64), you need to prepare the USB disk for loading. In general terms, you need to clear the disk of information, create 2 partitions, one of which will be EFI (fat32, 300Mb, 4kb), and the second will be the main (NTFS, 1Tb, 64kb) to host our VHDX container.
We connect the disk to the computer, run diskpart.exe.
We look at the list of disks:
DISKPART> list disk
Диск ###  Состояние      Размер   Свободно Дин  GPT
  --------  -------------  -------  -------  ---  ---
  Диск 0    В сети         1863 Gбайт  1024 Kбайт
  Диск 1    В сети          931 Gбайт      0 байт
  Диск 2    В сети          931 Gбайт      0 байт        *
* Диск 3    В сети         1397 Gбайт      0 байт        *
  Диск 5    В сети          931 Gбайт      0 байт        *

We select a disk with which we will work. This is usually done in size.
Attention! if you make a mistake, you can completely erase the system and data from the computer!
DISKPART> select disk 3
Выбран диск 3.

Next, you need to clear the disk of all the information:
DiskPart: очистка диска выполнена успешно.

Next, convert the disk to GPT disk:
DISKPART> convert gpt
DiskPart: выбранный диск успешно преобразован к формату GPT.

Next, create the first section where the EFI bootloader will be stored. We will do it in the size of 300MB, and the size of the stripe is 4kb (usually you need to test which size of the stripe will work faster, but I make the strips as large as possible, because the file sizes in our time are usually more than 4 or even 64 KB.):
DISKPART> create partition efi size=300
DiskPart: указанный раздел успешно создан.

Now it needs to be formatted in FAT32 format (only this format supports UEFI technology):
DISKPART> format fs=fat32 quick unit=4k
  Завершено (в процентах): 100
Программа DiskPart успешно отформатировала том.

Now you need to assign the drive letter to this partition in order to work with it (in our case it will be the letter Y):
DISKPART> assign letter=y
DiskPart: назначение имени диска или точки подключения выполнено успешно.

Now we need to mark up the rest of the disk where the rayserv.vhdx file will lie. First, create a section:
DISKPART> create partition primary
DiskPart: указанный раздел успешно создан.

Now format it in NTFS with a stripe size of 64kb:
DISKPART> format fs=ntfs quick unit=64k
  Завершено (в процентах): 100
Программа DiskPart успешно отформатировала том.

Now assign the letter Z to the section:
DISKPART> assign letter=z
DiskPart: назначение имени диска или точки подключения выполнено успешно.

Now you can close diskpart.exe:
Завершение работы DiskPart...

Now you can copy rayserv.vhdx to disk Z.
Next, you need to make some preparatory steps. It is necessary to connect a virtual disk to the system.

Since I work in Windows 7 x64, accordingly, my system does not support working with VHDX files. Therefore, I did not pre-make one system image file in VHDX, but two identical system images, only one in VHD format and the other in VHDX format. Currently, the VHD file is on the D: drive, and the VHDX file is already on the USB drive with the letter Z :. We connect the drive under the letter H :.

Now you need to make the EFI partition bootable.
Download the bootsect.exe file to drive D: (the file can be found using the Get Waik Tools utility, or on my page ). We start with the parameters:
D:\>bootsect.exe /nt60 y: /force
Target volumes will be updated with BOOTMGR compatible bootcode.
Y: (\Device\HarddiskVolume53)
    Successfully updated FAT32 filesystem bootcode.
Bootcode was successfully updated on all targeted volumes.

In order to copy the boot files to the EFI partition, go to the H: \ Windows \ System32 folder and run the command:
H:\Windows\System32>bcdboot.exe H:\Windows /s Y: /f uefi
Boot files successfully created.

Now you need to create to tell the system that you need to boot from the VHDX file. To do this, from the folder H: \ Windows \ System32 run:
H:\Windows\System32>bcdedit /store Y:\EFI\Microsoft\Boot\BCD /copy {default} /d "vhd boot (locate)"
The entry was successfully copied to {64d49e0f-ba36-11e3-8de2-1c6f653f47df}.

The / store switch indicates the path with which BCD file we need to work.
The resulting code {64d49e0f-ba36-11e3-8de2-1c6f653f47df} is stored or copied from the screen.
With this command, we copied the default boot entry and named it “vhd boot (locate)”.
Now give this number a default number:
H:\Windows\System32>bcdedit /store Y:\EFI\Microsoft\Boot\BCD /default {64d49e0f-ba36-11e3-8de2-1c6f653f47df}
Операция успешно завершена.

Now the system needs to indicate for this record that it is necessary to boot from a specific disk and a specific file.
H:\Windows\System32>bcdedit /store Y:\EFI\Microsoft\Boot\BCD /set {default} device vhd=[locate]\rayserv.vhdx
Операция успешно завершена.

H: \ Windows \ System32> bcdedit / store Y: \ EFI \ Microsoft \ Boot \ BCD / set {default} osdevice vhd = [locate] \ rayserv.vhdx The
operation completed successfully.

By the way, the [locate] parameter is very useful. He tells the operating system that when downloading, the file must be searched on all disks in order.

Now you need to enable auto-detection of devices at boot (this is required for some systems).
H:\Windows\System32>bcdedit /store Y:\EFI\Microsoft\Boot\BCD /set {default} detecthal on
Операция успешно завершена.

And finally, you need to disable autorun of the recovery console in case of problems:
H:\Windows\System32>bcdedit /store Y:\EFI\Microsoft\Boot\BCD /set {default} bootstatuspolicy ignoreallfailures
Операция успешно завершена.

Disconnect the virtual disk from the system through the disk control panel.

Almost done. Now on the final system you need to disconnect all disks, except ours, and enable UEFI boot in the BIOS for USB drives. It may also be necessary to increase the search timeout of USB devices, as With a cold start, the system may not see the external hard drive.
After that, boot from the USB drive.

At the first boot, my server did not start. I had to press F8 and choose a secure boot. Then the server worked, and after the reboot everything began to work as it should. It remains only to remove the timeout in the boot menu and everything will be ready. This can be done on the running system through the msconfig utility.

Also popular now: