I want to perform Linux fstrim
or Windows degrag retrim on a file system within VM to shrink VMware vSphere thin disks. However this should be performed only if there is no snapshot present as fstrim-ing a snapshoted file system will cause it to grow to full size on VMware vSphere thin disks.
Limitation: VM guest OS does not have access to vSphere/vCenter management interfaces.
Is there a way to detect presence of snapshot from within VM guest OS - for example via via VMware tools?
Q: Is there a way to detect presence of snapshot from within VM guest OS*
A: not that I know. However, you can use the
sg_vpd
to check if UNMAP is supported. For example:Some explanations:
provision type
is 2, so you are running from a "thin" disk;unmap command supported (LBPU)
is 1, so your disk claims to support UNMAP/TRIMThat said, issuing
fstrim
on a snapshotted disk should not have any adverse effect. On VMWare <= 6.5, it should have no effect at all, while VMWare >= 6.7 seems to support TRIM even when using snapshots.EDIT: as detailed in the comments below, the problem is related to original disk inflation during/after "trimmed" snapshot consolidation. As shown here, this side effect seems not avoidable even on latest VMWare 6.7