Jul 132014
 

If you have an SSD drive on your system, you may have added the discard option in /etc/fstab which will discard blocks not in use by the file system. Another way to achieve this is to use the fstrim command. Red Hat recommends use of fstrim over the discard option [1]. There is a nice article about TRIM [2] that explains why:

In order to optimize the performance of the SSD, I strongly advise you to avoid doing the TRIM operation in real time (whenever a file is deleted) because you would be putting an unnecessary extra amount of work over the SSD. In other words: You should not enable the discard option in fstab.
Instead, what I recommend is to run a script periodically to tell the SSD which blocks are free with the command fstrim. Doing this operation daily or weekly is more than enough. This way we do not lose any performance due to TRIM when deleting files and we periodically keep informed the SSD about the free blocks.

The article also describes some other advantages of fstrim.

Unless you really need online discard operations for performance, just discard that ‘discard’ option. đŸ™‚

Note added: there is an article about SSD optimization worth reading [3].

[1] https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch02s04.html
[2] http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/
[3] https://wiki.debian.org/SSDOptimization/

  3 Responses to “Discard that ‘discard’ — Run fstrim on RHEL and rebuilds”

  1. can discard option be used if am running vm esxi 5.5 which has a directory on NAS mounted .OS is RHEL6. however the due to read write there is a chokage,which cause load to increase on vm and umount and mount of directory solves the problem temporarily..Will discard option help to reduce the wait states of write operations??

  2. Depends is the NAS a linux NAS, what kind of storage is it using ? SSD’s or magnetic storage (regular HDD’s) For regular storage it is better to defragment the drives rather than use fstrim. If it’s SSD’s then performance may improve but here performance penalty is because of virtualisation and also accessing a NAS in a virtualised environment using SSD’s for the NAS may help.

  3. You can probably run the discard option on the NAS device itself. If the NAS is a regular PC running linux with some HDD’s. I dont think you can run it from the vm. Also fstrim/discard makes sense only if the Nas has SSD’s if it is regular HDD’s then a defragmentation may improve performance (defrag is bad for SSD’s). But in your case latency is introduced by several factors 1) virtualisation of OS in esxi 2) Network latency because network may be shared by more vm’s and host needs to transfer packets to vm’s virtualised nic’s even if there is only one vm 3) processing of the vm host 4) processing and specifications of the NAS device

Sorry, the comment form is closed at this time.