다음을 통해 공유


VHD Bootable with custom image via sysprep - Complete Guide

With the evolution of virtual devices it is now possible to apply Operating Systems to native VHD disks simulating common HD's at startup using simple tools like diskpart and some commands.This step-by-step guide shows you from the beginning of the procedure to the end for anyone who wants to adopt this technology from scratch, starting with creating a Virtual Machine, through its personalization until the final moment that is adding the input of the boot as default. So let's start ;)

On your local machine the following features are required:

Microsoft Windows ADK
Click here to download ADK and WindowsPE

  • (ACT) Application Compatibility Toolkit.
  • Deployment Tool.
  • Windows Preinstallation Environment (Windows PE).

And also:
VMWare WorkStation which can be found in Trial version for 30-day testing.
You will need a pendrive to save the WindowsPE image and an External Drive to save  the VHD and the image that will be generated by the Dism capture. That is, the total operating system custom in VMWare + the VHD.

1. First step:
Install VMWare Workstation Pro on Your Local Machine and install the Operating System.
Install in this Operating System the Applications of your preference.

2. Second step:
Run Sysprep

  • C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /shutdown

3. Third step:
Use the Windows ADK Deployment Tool To generate a Windows PE Pendrive - As Administrator open the Deployment Tool Environment prompt - Make a copy of the WindowsPE files. (Cite the Platform)

  • Copype amd64 c:\WinPE_amd64
  • MakeWinPEMedia /UFD C:\WinPE_amd64 F:

4. Fourth step:
Add the pendrive in Removable Devices and configure VMware to start in Firmware mode both in the VM option menu. In Firmware choose to boot from USB device

5. Step Five:
Check the drive letter of each drive, such as the drive letter of the external drive, the drive where Windows is installed, and the drive letter of the virtual drive that is usually X: \
With these checked items we will capture the Windows installation to an empty folder from the External Drive

At the command prompt type:

  • X:\
  • Dism /Capture-Image /ImageFile:F:\Imagem\Windows.wim /captureDir:C:\ /Name:”Windows”

6. Sixth step:
Start Diskpart
At the command prompt type:
Diskpart
Create and prepare a new VHD.

  • create vdisk file = F: \ Image \ windows.vhd maximum = 500000 type = fixed or expandable

Attach the VHD. The VHD is added as a disk to the host storage controller.

  • attach vdisk

Create a partition for the Windows files, format it, and assign a drive letter.

  • create partition primary (Remember you can abbreviate the command) ex: create partiti pri;)
  • format quick label = vhd
  • assign letter = v

Exit Diskpart.

  • Exit

7. Seventh step
Apply a generalized Windows image to the primary VHD partition.

  • Dism / Apply-Image /ImageFile:F:\Image\windows.wim / index: 1 / ApplyDir: V: \

8. Eighth step
Detach the virtual disk.

  • diskpart
  • select vdisk file=F:\Imagem\windows.vhd
  • detach vdisk
  • exit

9. Ninth step
Start the target device in WindowsPE (Windows Preinstallation Environment).
Clean and prepare the unit. Create a system partition (S) and a main partition (M) on which the VHD will be stored.

UEFI:

  • diskpart
  • select disk 0
  • clean
  • convert gpt

____ Partition System____

  • create parti efi size = 200
  • format quick fs = fat32 label = System
  • assign letter = "S"

2. ____ System Recovery Partition (MSR) ____

  • create partiti msr size = 500
  1. ____ Main Partition (Main) _______
  • create partiti pri
  • format quick fs = ntfs label = Main
  • assign letter = M
  • exit

Connect a storage location and write down the drive letter.

10.Tenth step:

Copy the VHD to the main partition.

M: \
M: \ copy F: \ Image \ windows.vhd

11. Eleventh step:

Attach the VHD.

  • diskpart
  • select vdisk file = M: \ windows.vhd
  • attach vdisk

Identify the volume letter. (Optional: change to another appropriate letter, for example, V, and leave the diskpart command line open for the next step).

  • list volume
  • select volume 3
  • assign letter = v

Open Diskpart (if necessary) and identify the drive letters of the VHD and system partition, for example, V and S.

  • diskpart
  • list volume
  • exit

12. Twelfth step

Add a boot entry to the device.
UEFI:

  • V: \
  • cd windows \ system32
  • bcdboot v: \ windows / s S: / f UEFI

Remove the USB key from Windows PE.

Restart the device.

Sources:
Inicializar no VHD (início nativo): adicionar um disco rígido virtual ao menu de inicialização
Microsoft Windows ADK
Windows 8 ADK Criando o Windows PE