SSD TRIM and Dual-Drive Hybrid Systems on Linux

If your SSD support TRIM but still becomes slower after long run, try to check if you have enable it in Linux. In some case, you need to manually TRIM these in offline mode.

You may use it as a single drive or mixed with hard drive as a dual drive hybrid systems on Linux.


Wiki explains trim on Linux very clearly:

Initial support for discard operations was added for FTL NAND flash devices in 2.6.28. Support for the ATA Trim command was added in 2.6.33.

Not all filesystems make use of Trim. Among the filesystems that can issue Trim requests automatically are Ext4, Btrfs, FAT, GFS2 and XFS. However, this is disabled by default due to performance concerns, but can be enabled by setting the “discard” mount option. Ext3, NILFS2 and OCFS2 offer ioctls to perform offline trimming. The Trim specification calls for supporting a list of trim ranges, but as of kernel 3.0 trim is only invoked with a single range that is slower.

Therefore, use uname -a to see you Linux kernel version. Don’t forget to check if your SSD supports TRIM, too.

For NAS from QNAP, there is a SSD compatibility list.

Noted. TRIM doesn’t work for RAID.

Verify TRIM in Linux is Enabled

How to Know if TRIM Is Working in Linux by Tiffany Garden from Demand Media explains every steps very clearly. Just run hdparm -I and looking for “discard” or “Data Set Management TRIM supported”. More detail about this command may be found in Linux Commands. QNAP need to install with ipkg install hdparm first.

Here is what I got from my notebook with SSD running Ubuntu 14.04 LTS.

~$ sudo hdparm -I /dev/sda2 | grep TRIM
 * Data Set Management TRIM supported (limit 1 block)
 * Deterministic read data after TRIM

If it is not enabled, edit your /etc/fstab file and add “discard” in options which is explained in SSD discard (trim) support on OpenSUSE SDB as below.

Discard is the linux term for telling a storage device that sectors are no longer storing valid data and applies equally to both ATA and SCSI devices. ie. For ext4 filesystems, there is a discard mount option, not a trim or unmap option.

Reboot to take effect and run mount to see if the option is used while mounting SSD partitions.

~$ sudo mount | grep root
/dev/mapper/ubuntu--vg-root on / type ext4 (rw,errors=remount-ro,discard)

Manually TRIMing

According to Didier (or PiroNet) in QNAP NAS Community Forum: Trim for SSDs, he quotes following words by Mark Lord on native Trim in Linux kernel to explain why you need to Trim with manually.

There has been a TRIM add-on for the Linux kernel (“native TRIM”) available for many months now, but it has not gone mainstream yet due to lack of real TRIM hardware for testing it.

Now that we have real TRIM hardware, that add-on has proven inadequate (slows things down way too much), so some redesign / rework is necessary before it can go mainstream.

The lead developer, Matthew Wilcox, is mulling over the design now, with contributions from myself and several other key Linux kernel people.

This process will take several months, which is why I created for use in the interim. Heck, one of the better longer term proposals is to stick with something like this, but with improved kernel integration/support for it.

In SSD discard (trim) support, it recommends to use with OpenSuSE prior to 11.4 (Linux kernel 2.3.37 according to openSUSE on Wiki) manually. Use fstrim in util-linux package with and after 11.4.

You may check Linux kernel version on you NAS in phpinfo() Reports on NAS.

Here is a sample running fstrim on my notebook. It might be different on your computer.

~$ sudo fstrim / -v
/: 164952039424 bytes were trimmed

If you need to use, it could be download from hdparm files on SourceForge. OCZ Vertex-LE users need partition your drive excluding the last sector to avoid error. It works for read-write mounted ext4 and xfs, and for read-only mounted/unmounted ext2, ext3, ext4, reiser3, and xfs. Don’t use it with btrfs.

On How To Get Running On QNAP Storage Devices To TRIM SSDs?, Didier list all the steps from install packages to modify script files and includes trouble shooting.

SSD as Cache for Hybrid Drive

Like most hybrid drive or SSHD, you may use SSD and hard drive to build dual drive hybrid systems. You will need a special kernel level program to achieve this in Linux. Here is a list of your choice:

  1. bcache: still maintained on official website.
  2. dm-cache: didn’t update for more than two years on GitHub.
  3. Flashcache: developed by Facebook.
  4. EnhancedIO: a fork of Flashcache by sTec which has been acquired by HGST, a Western Digital company on Sep 12, 2013.

There is also a short and interesting comparison on bcache and dm-cache in LSFMM: Caching — dm-cache and bcache by Jake Edge.


  1. Wiki: Trim (computing)
  2. Wiki: Hybrid drive: Dual drive hybrid systems
  3. QNAP
  4. QNAP: Compatibility list: SSD
  5. Wiki: Standard RAID levels
  6. QNAP NAS Community Forum: TS459 Pro+ compatibility with OCZ SSD’s and TRIM support
  7. QNAP NAS Community Forum: Trim for SSDs
  8. How to Know if TRIM Is Working in Linux
  9. Linux Commands Examples: hdparm
  10. OpenSuSE: SDB:SSD discard (trim) support
  11. SourceForge: hdparm files
  12. QNAP NAS Community Forum: TRIMing using – need assistance!
  13. Wiki: openSUSE
  14. phpinfo() Reports on NAS
  15. DeinosCloud: How To Get Running On QNAP Storage Devices To TRIM SSDs?
  16. Wiki: Hybrid drive
  17. Wiki: bcache
  18. bcache Official Website
  19. Wiki: dm-cache
  20. GitHub: mingzhao / dm-cache
  21. Wiki: Flashcache
  22. GitHub: stec-inc / EnhancedIO: EnhancedIO Open Source fir Linux
  23. LSFMM: Caching — dm-cache and bcache

4 thoughts on “SSD TRIM and Dual-Drive Hybrid Systems on Linux

  1. In your last section “SSD as Cache for Hybrid Drive,” I assume you discuss the case of software-managed “SSHDs”, out of a dual drive systems. If that is correct, then the phrase “to build dual drive hybrid systems” is not really accurate. More precisely, you discuss taking two (for “dual drive” case) disks, visible to software as independent, and create the functionality of an SSHD, i.e., a slow drive transparently cached via a faster one. So, the resulting system is not a “dual drive hybrid,” but a software SSHD.

    Am I right?

    Liked by 1 person

    1. Dear Stamatis,

      In SSD as Cache for Hybrid Drive, it requires a SSD and a traditional hard drive. A software will use SSD as cache to speed-up disk I/O. The result is one logical drive from operating system. dual-drive means two physical drive.

      I am not sure if I got your point.

      Have a nice day!

      Best regards,


      Liked by 1 person

      1. Hi Amigo,

        My point is simple. Available hardware (HW) products use the terms “SSHD” (hybrid) for HW-managed combination of SSD and traditional disks, and “dual drive” for separate drives in the same HW package one of which is an SSD, but which provides separate interfaces to software (SW). This is in contradiction with the way you use the terms and, thus, creates some confusion (at least, it confused me at first, when I read it).

        After thinking about it, I disagree with the way you use the term “dual drive hybrid,” because you refer to a SW construct, which does not include anything inside it that can be meaningfully termed a “dual drive”. Any formulation of a system that includes an SSD and a traditional drive, can be used to for what you call “dual drive hybrid”. It does not need to include what HW manufacturers call a “dual drive”; it can be any setup of independent drives (even over HW interfaces adversely affecting the SSD caching of the traditional drive in the setup, or including more than just two drives, though such SW is not yet present).

        Thus, I believe, the proper term, of what you are referring to, should be “software hybrid drive” and not “dual drive hybrid,” as it does not include anything meaningfully termed “dual drive” and it could possibly use more complex setups in the future.

        Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.