The preceding page covered DiskPart usage for setting up the external USB disk. This page covers DiskPart usage for creating a virtual hard disk, which will be used as the target for the Windows To Go installation.
create vdisk file=S:\win2go.vhd maximum=30720 type=fixed - adjust path, size (in MiB) and disk type as required.
select vdisk file=S:\win2go.vhd - select the virtual hard disk created in the preceding step - adjust path as required.
create partition primary - create a partition spanning the full size of the selected VHD file.
format fs=ntfs label=Win2Go quick - format using the NTFS filesystem. Edit the label as required.
active - mark the partition as active / bootable. This is not required if booting on UEFI firmware, but is required if booting on BIOS systems and UEFI in compatibility mode (CSM).
assign letter=t - mount the partition as drive/volume T:\.
Diskpart can be scripted. The following is a script file to automate the commands listed above (replace "select disk #" with the correct disk number) -
Save as D:\walkthrough2vhd.txt and then run the following command from an elevated command prompt (run as Administrator). Adjust path and filename as required -
Output from running the command DiskPart /S D:\walkthrough2vhd.txt
Document date - 6th July 2022