Its been long time reclaiming space on a block level storage, been alerting and frustrating for all who work on 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, the space is not marked as unused in storage side or cannot see changes on storage GUI/ Interface.
Even its been discussed for a while , now its introduced unmap/trim feature on Operating system (file system level) that helps to reclaim space. On Linux below filesystem have this features.
Its been already there on ESX 5 and later due to some performance issue remove in update 1. Now its been introduced on Window 2012 server. So its happy days for all system managers :-). This would be much useful for many business who are using block level storage like Equallogic , Compellent etc.
On linux its 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.
[[email protected] ~]# mkfs.ext4 /dev/sdb1
[[email protected] ~]# 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 can be downloaded from Sourceforge