Sunday, April 2, 2017

How to Compact VHD file




C:\Users\administrator.ULC>diskpart

Microsoft DiskPart version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation.
On computer: <Server Name>

DISKPART> select vdisk FILE=F:\VMs\ServerMedia\VMName.vhd

DiskPart successfully selected the virtual disk file.

DISKPART> attach vdisk readonly

Virtual Disk Service error:
The virtual disk is already attached.


DISKPART> compact vdisk

Virtual Disk Service error:
The requested operation requires that the virtual disk be
attached read only.


DISKPART> detach vdisk

DiskPart successfully detached the virtual disk file.

DISKPART> attach vdisk readonly

  100 percent completed

DiskPart successfully attached the virtual disk file.

DISKPART> compact vdisk

  100 percent completed

DiskPart successfully compacted the virtual disk file.

DISKPART> attach vdisk readonly

Virtual Disk Service error:
The virtual disk is already attached.


DISKPART> detach vdisk

DiskPart successfully detached the virtual disk file.

DISKPART>

No comments: