govmomi
govmomi copied to clipboard
govc: datastore.disk.shrink doesn't appear to thin disk size
Hello! I'm trying to thin a VMDK using govc datastore.disk.shrink
. However, once I run the command on the VMDK, it finishes almost immediately, and the space doesn't appear to change. I see the task execute in vSphere, but the VMDK is still as large as before. Migrating the VM between datastores from vCenter works fine however, so I believe I'm not zeroing the disk incorrectly. Is there something wrong with what I'm doing? The only other way to thin I know of is to use vmkfstools --punchzero
on the host, but I don't have SSH access run it.
$ govc datastore.disk.shrink -ds=/MyDc/datastore/DataStoreCluster/Datastore123 NAME-OF-VM/NAME-OF-VM.vmdk
[26-06-20 11:34:06] Shrinking [Datastore123] NAME-OF-VM/NAME-OF-VM.vmdk...OK
ShrinkVirtualDisk_Task doc says:
Shrink a sparse virtual disk.
Which disk type are you trying to shrink?
It's a thin virtual disk -- is that supported? Sorry, I'm not very clear on the distinguishment between a sparse and a thin disk. I don't recall ever seeing a 'sparse' option when provisioning but then again I'm no expert. Running vSphere 6.5.0 if it makes a difference.
$ govc datastore.disk.info -ds=/MyDc/datastore/DataStoreCluster/Datastore123 NAME-OF-VM/NAME-OF-VM.vmdk
Name: NAME-OF-VM/NAME-OF-VM.vmdk
Type: thin
Parent:
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen
. Mark the issue as
fresh by adding the comment /remove-lifecycle stale
.
/remove-lifecycle stale
Isn't explicitly needed by my workflow anymore, but still deserves a peek IMO if there are cycles to spare
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Mark as fresh by adding the comment /remove-lifecycle stale
.
Is there a way to disable the inactivity bot? Would rather not close this as it isn't resolved, but if the bot keeps pestering & the maintainers want to close this so be it.
/remove-lifecycle stale
@embano1 any pointers? Other projects such as Kubernetes have a label (e.g. lifecycle/frozen) that can be added for this.
Regarding the issue itself.. To shrink the size of the vmdk, you probably need to zero out unused disk space from inside the VM.
Have seen it done in VMs built by packer, example here: https://github.com/boxcutter/ubuntu/blob/aa1bba14aeafa54a49d41787cb970bb2127c6b67/script/cleanup.sh#L55
While the packer scripts are meant to shrink the exported vmdk, I assume this approach would also apply to ShrinkVirtualDisk_Task
, but have yet to try myself.
I believe even with zeroing out the free space, the shrink command wasn't restoring the space, which is why we migrate back and forth between a datastore before the using the image.
@embano1 any pointers? Other projects such as Kubernetes have a label (e.g. lifecycle/frozen) that can be added for this.
That is exactly the label (lifecycle/frozen
) the bot will use to determine whether to skip stale issue/PR.