Українською

Using diskpart example

Date: 06.11.2024

Start diskpart as an Administrator, then type this sequence:

DISKPART>sel vdisk file=A:\full\path\to\your.vhd
...
DISKPART>attach vdisk
...
DISKPART>lis dis

At this point, diskpart will list available disks. You need to define your VHD's number N. By recognizing by size and free space available for example. Or by distinguishing from other, already formatted disks. Be carefull! Make sure, you've defined the number N correctly, exactly of your freshly created empty VHD and only then proceed to:

DISKPART>sel dis N
...
DISKPART>lis par

Here, if you picked the number N correctly, for your empty VHD, diskpart will tell you, that there are no partitions on this disk. Good! Otherwise, the number is wrong! Go back and select the correct number. Only after you've done so, proceed to:

DISKPART>create par primary
...
DISKPART>lis par

Now, diskpart creates and then lists that only just created partition, that with these "create" command parameters, will span all the available disk space — all we need for an installation medium. Now format it and then mount. In the below example, we format it as FAT16 and mount as drive A. For having it as FAT32, you need to create VHD of the size, bigger, than 32MB. Then fs=fat32 option will be accepted:

DISKPART>format fs=fat label=YourLabel
...
DISKPART>assign letter A

After this accomplished successfully, you can unpack the archive's content into A: and then, unmount the drive and detach VHD:

DISKPART>remove letter A
...
DISKPART>detach vdisk

And now, it's ready for attaching to the VM.