On my Linux Mint 17.2 VMware guest,
df -h was reporting my total disk usage steady at about 10GB total. I'm using this machine for Ruby on Rails development inside a Windows host running Workstation 12.1.1 Pro.
*.vmdk files kept on steadily growing to approx 100GB. Trying to shrink with
vmware-vdiskmanager -k or
vmware-toolbox-cmd disk shrinkonly made no difference.
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize. A more complete
dumpe2fs output is available.
e4defrag / and
e2fsck -E discard didn't allow any more space to be reclaimed (I killed the shrink after the first few vmdks (which started at around 6GB) showed no sign of shrinking.)
What finally did the trick was filling all free space with
dd if=/dev/zero of=wipefile bs=1M; sync; rm wipefile
I could now shrink to a total
*.vmdk size of 15.6GB with
vmware-toolbox-cmd disk shrinkonly.
That's about 85GB space saving on a VM with 10GB actual data.
It seems that
ext4 is not re-using previously used blocks when asked for an unused block, often preferring to give out never-before-used blocks.
Having old data hanging around longer seems less secure. Why would
ext4not re-use recently-used blocks as soon as possible?
Is there a way to force
ext4to reuse just-used blocks?
Is there a way to prevent a VMware guest's
*.vmdkfiles from continually growing without needing to
0-fill free space on a regular basis?
- How do you safely (eg not entirely filling the filesystem) automate this?