Shrink guest on hosted platform: Difference between revisions
→Zero out using fstrim
(→Zero out using fstrim: adding a small example) |
|||
Line 109: | Line 109: | ||
* [https://github.com/vmware/open-vm-tools/issues/457 Avoid disk expansion while shrinking (github issue tracker)] | * [https://github.com/vmware/open-vm-tools/issues/457 Avoid disk expansion while shrinking (github issue tracker)] | ||
On most modern systems fstrim is being run automatically using systemctl. You can check if it is enabled: | |||
# systemctl status fstrim.timer | |||
● fstrim.timer - Discard unused blocks once a week | |||
Loaded: loaded (/lib/systemd/system/fstrim.timer; disabled; vendor preset: enabled) | |||
Active: inactive (dead) | |||
Trigger: n/a | |||
Triggers: ● fstrim.service | |||
Docs: man:fstrim | |||
Oh-huh, our system does not have it enabled.. might there be a reason, such as that the UNMAP command is not supported? | |||
If so, the following command would return 0. | |||
# cat /sys/block/sda/queue/discard_max_bytes | |||
1073741824 | |||
So UNMAP is supported, but fstrim still is not enabled, lets fix that. | |||
# systemctl enable fstrim.timer | |||
Created symlink /etc/systemd/system/timers.target.wants/fstrim.timer → /lib/systemd/system/fstrim.timer. | |||
and reload systemctl plus check that it now works... | |||
# systemctl start fstrim.timer | |||
# systemctl daemon-reload | |||
# systemctl status fstrim.timer | |||
● fstrim.timer - Discard unused blocks once a week | |||
Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled) | |||
Active: active (waiting) since Sat 2024-01-06 13:00:46 CET; 6s ago | |||
Trigger: Mon 2024-01-08 01:17:59 CET; 1 day 12h left | |||
Triggers: ● fstrim.service | |||
Docs: man:fstrim | |||
see also: | |||
* https://www.suse.com/support/kb/doc/?id=000019447 | |||
== Zero out unused space on a Windows VM == | == Zero out unused space on a Windows VM == |