Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

govc: datastore.disk.shrink doesn't appear to thin disk size #2035

Open
HeroCC opened this issue Jun 26, 2020 · 9 comments
Open

govc: datastore.disk.shrink doesn't appear to thin disk size #2035

HeroCC opened this issue Jun 26, 2020 · 9 comments

Comments

@HeroCC
Copy link

HeroCC commented Jun 26, 2020

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
@dougm
Copy link
Member

dougm commented Jun 26, 2020

ShrinkVirtualDisk_Task doc says:

Shrink a sparse virtual disk.

Which disk type are you trying to shrink?

@HeroCC
Copy link
Author

HeroCC commented Jun 26, 2020

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:

@github-actions
Copy link
Contributor

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.

@HeroCC
Copy link
Author

HeroCC commented Mar 24, 2021

/remove-lifecycle stale

Isn't explicitly needed by my workflow anymore, but still deserves a peek IMO if there are cycles to spare

@github-actions
Copy link
Contributor

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.

@HeroCC
Copy link
Author

HeroCC commented Jun 27, 2021

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

@dougm
Copy link
Member

dougm commented Jun 28, 2021

@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.

@HeroCC
Copy link
Author

HeroCC commented Jun 28, 2021

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
Copy link
Contributor

embano1 commented Jun 29, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants