Its been a long time reclaiming space on block-level storage, been alerting and frustrating for all who work on the storage side. Block storage only knows about areas of a volume that have ever been written. If later the application frees up space/delete files, space is not marked as unused in the storage side or cannot see changes in storage GUI/Interface.
Even its been discussed for a while, now its introduced unmap/trim feature on the Operating system (file system level) that helps to reclaim space. On Linux below filesystem have these features.
ext4 (v2.6.36-rc6-35-g7360d17) ext3 (v2.6.37-11-g9c52749) xfs (v2.6.37-rc4-63-ga46db60)
Its been already there on ESX 5 and later due to some performance issue remove in update 1. Now it's been introduced on Windows 2012 server. So it's happy days for all system managers :-). This would be much useful for many businesses who are using block-level storage like Equallogic, Compellent etc.
On Linux, it's simple enough it mount the filesystem with discard option. I have tested this in Redhat 6.0.1 and it was successful. The Kernel should support TRIM feature and file system must include FITRIM support. This feature was included from Linux kernel 2.6.38.
This feature can be verified by check /sys/block//queue/discard_max_bytes. If the value is zero then it support discard option.
[root@server1 ~]# mkfs.ext4 /dev/sdb1 [root@server1 ~]# mount -o discard /dev/sdb1 /apps
The /etc/fstab should look as below
/dev/sdb1 /apps ext4 defaults,discard 0 1
There are two types of "discard" are there. They are:
1) Realtime discard mode
2) Batch mode
The Realtime discard is the one I showed above and in this mode it issues discard requests automatically as files are deleted from the filesystem (no user action). But it have slight performance issues. But second option Batch Mode would need user action and the user need to run the command manually. The command is as below.
# fstrim /apps
Fstrim can be downloaded from Sourceforge