Random Culprits‎ > ‎

Linux Filesystems for Modern SSDs and TRIM Support

posted Nov 14, 2010, 11:12 AM by Nicolay Doytchev   [ updated Mar 29, 2012, 7:56 PM ]

It seems that the question of which filesystem is suitable for use with modern SSDs (Solid State Drives) on Linux and why hasn't been clearly answered. For that reason I am reporting what I learned through my experiences as a user of both technologies.

First, what do I refer to when I say "a modern SSD". This term encompasses a few other terms you might have heard such as "second generation SSD" or "smart SSD". A modern SSD is an SSD that has been manufactured recently - after the first half of 2009. Most of those SSDs use very smart controllers that support ATA_TRIM and perform very aggressive wear-leveling and parallelization. An SSD that possesses these features does not need extra special care from the operating system such as the use of log-based filesystem. The only thing a modern SSD needs from the filesystem is TRIM commands to be issued whenever files are deleted.

Now let's examine what are the requirements for a filesystem suitable for use with modern SSDs:

  • The filesystem has to be able to issue ATA_TRIM commands to the underlying SSD
  • The filesystem must not perform unneeded writes to the disk

As of Linux 2.6.36 there are two major filesystems which cover both requirements. These are:

Of those two Btrfs is considered unstable as of Linux 2.6.36 which leaves us with an easy choice - Ext4. Ext4 provides both TRIM support and write optimizations such as write caching. Fortunately some of the most popular GNU/Linux distributions such as Ubuntu and Fedora ship with support for Ext4. In fact Ext4 is the default filesystem used by those to format your disk partitions for some time now. Unfortunately Ext4 supports TRIM only since Linux 2.6.33 which might not be what is under the hood of your distribution. For example Ubuntu 10.04 ships with Linux 2.6.32, therefore it does not support TRIM out of the box.

We now know that Ext4 is suitable for use with an SSD provided that we have Linux 2.6.33 or greater. However there are several other requirements we need to cover in order to use it successfully with an SSD. These are:

  • Partitions need to be aligned to the block size of the SSD
  • TRIM must be explicitly enabled for each Ext4 formatted partition

The installers of Ubuntu 10.04 and later do align all partitions they create at the 1024KB border which should fit most if not all modern SSDs. If you are not using Ubuntu, current versions of fdisk would also create partitions at the 1024KB border if started with the "-cu" flags.

As of current there is no automated way to enable TRIM for Ext4 formatted partitions. However manually enabling it isn't far from trivial. It is as simple as adding "discard" to the list of mount options for each Ext4 partition in your "/etc/fstab" file. For more details on that head off to this HOWTO in the Random Culprits section.

With those requirements covered you should be able to use Ext4 on your your SSD.

Finally I hope that now you have a better understanding of the status of Linux on modern SSDs.

Comments