1. Home
  2. Linux
  3. Optimize an ssd on linux

How To Optimize An SSD On Linux

SSDs are getting more and more support for Linux these days, and more and more users are getting their hands on them. Despite this, not many Linux users know what the correct file system is that they should use, how file system TRIM works, or even why they should be careful about read/writes. That’s why in this article we’re going to break down everything there is to know about optimizing an SSD on Linux. We’ll go over the best file systems to use. In addition to this, we’ll go over how to enable TRIM, and more!
SPOILER ALERT: Scroll down and watch the video tutorial at the end of this article.

File System For SSD

Solid State Drives are very modern. They take advantage of NAND technology to ensure that your data is read and written in the fastest way possible. It is because of this speed, solid state drives tend to be really fast no matter what type of file system you put on it. That said, if you’re looking to get the most out of your SSD on Linux, your best bet is to choose the best file-system for it. Let’s go over the file systems available for Linux, and discuss what ones are best to use on an SSD.

Extended 4

The Extended 4 file system is the file system of choice for most Linux distributions for a reason. It’s reliable, and has pretty good features for a variety of use-cases. Ext4 is generally an “all-purpose” file system, meaning that it’s expected to be in use on a variety of different storage devices. It’s not specifically designed just for an SSD, but don’t let that scare you. It has a lot of improvements specifically for SSD owners like TRIM support, and features that allow the reduction of read/writes to improve longevity.

If you’re not sure what you want out of your SSD go with this file system. It’s well rounded and will get the job done.

XFS

The XFS file system is an older file system with a lot of different use-cases.  Like Ext4, the XFS file system supports things like TRIM, which will keep your SSD healthy on Linux. In addition to this, it has some really great features, including  a file-system defragmentation tool, and the ability to disable file system journaling (which is critical when trying to maximize the longevity of your SSD).

Overall, XFS is a great file system for SSDs, if you’re looking to get the absolute best performance possible. The XFS file system is select-able from most Linux distribution installation tools.

Enable TRIM Support

FS-TRIM is a tool for file systems that goes through and discards unused blocks. Due to the nature of flash memory and NAND in general, the more blocks that pop up, the slower an SSD can become over time. This is very important for the health of a Solid State Drive that you enable this feature.

For the most part, Linux distributions (like Ubuntu, and etc) will enable it for you. However, not every Linux distribution is created equal, and some do not enable this feature by default. Here’s how to do it:

Ubuntu

sudo apt install util-linux

Debian

sudo apt-get install util-linux

Arch Linux

sudo pacman -S util-linux

Fedora

sudo dnf install util-linux

OpenSUSE

sudo zypper install util-linux

With the util software installed, enable the systemd services to ensure FS-TRIM runs.

sudo systemctl enable fstrim.service
sudo systemctl enable fstrim.timer

Then, start the two services right away with systemctl start.

sudo systemctl start fstrim.service
sudo systemctl start fstrim.timer

Reduce Read And Writing On SSD

Solid State Drives do not work the same way as a traditional, spinning hard drive. Unlike RPM drives, SSDs have a finite amount of writes they can perform. Once the user reaches the maximum writes possible, the drive will become read-only and start to fail (or worse). To mitigate this, do the following.

First, do not create a swap partition on your SSD. Giving an entire partition to swap on an SSD means that the solid state drive is constantly reading and writing data. This can quickly degrade the health and life of the drive. Instead, consider making a swap file, or forgoing swap altogether.

Using a swap file rather than a partition is still iffy, but it’ll ultimately be better, because a swap file is still just a file and not an entire partition the system can use. In addition, swap files are easy to turn off and on. A user can easily turn on swap when needed, and turn it off right away when done, resize it and etc. Swap partitions are less flexible.

Another good practice to mitigate read/writes on your SSD is to disable journaling with your file system. It’s not critical, but if you do it you’ll read/write significantly less. To do this, search your Linux distribution’s manual for any information they may have on this specific to your operating system.

Lastly, always try to update your SSD’s firmware. Believe it or not, but SSDs get updates like any other component on your PC. If you don’t update the firmware, you miss out on improvements from the manufacturer that make it more efficient, read/write less and handle data better. To update your drive’s firmware, it’s best to refer to the manual that comes with your SSD. Alternatively, search for the manufacturer’s website, or look through your Linux distribution’s Wiki for instructions.