SSD: how to optimize your Solid State Drive for Linux Mint and Ubuntu


Back to the home page


Below you'll find a complete how-to for optimizing your SSD for Linux Mint 19.2 and for Ubuntu 18.04. So that you'll be able to enjoy your SSD for many years!


Contents of this page:

Avoid exaggerated measures

1. First a word of caution: don't exaggerate! There's a lot of exaggeration to be found on the web on this issue.

On the one hand you have people who don't take any special measures for SSD's at all, and on the other hand you see people who take all kinds of extreme and complicated precautions. Neither side is behaving very sensibly.

This how-to is meant to be a "best practice". It'll show you how to achieve a very good result by applying just a few rather simple measures. With those, you'll be able to enjoy your SSD carefree, for years and years to come!

Taking into account the long warranty periods that the manufacturers are giving, probably for more than five years (10 years should be a reasonable expectation). Considerably longer than an ordinary platter hard disk, anyway...

Alignment is not necessary anymore

1.1. A common misunderstanding is, that the partitions on the SSD should be properly aligned first. That used to be true years ago, but no longer.

In all current versions of Ubuntu, Linux Mint and Debian, all tools automatically align filesystems and partitions to the optimal 4096 byte page size. So there's no need to do anything for alignment on an SSD.

BIOS and UEFI: make sure it's set to AHCI

2. A Solid State Disk, or rather Drive (SSD), is usually only recognized properly by the BIOS or UEFI, when in the BIOS/UEFI the feature AHCI has been activated for SATA (instead of IDE).

This feature may be hard to find in the BIOS/UEFI, because there's absolutely no standardization at all in menu structures for BIOS and UEFI (sigh....).

That's why I've made two screen shots of the BIOS of my computer, in which you can see this particular feature. Hopefully it'll help you to find it in your own BIOS/UEFI.... The motherboard of my computer is, by the way, an MSI H61MA-E35 (B3).

Note: doesn't the BIOS or UEFI of your computer offer the option to switch to AHCI? In relatively modern computers that's probably no problem: the BIOS/UEFI will then usually detect the SSD automatically, and automatically select the right BIOS settings for it.

First of all, in the BIOS of my computer I go to the tab Advanced, and there I expand the section Integrated Peripherals (click on the image below to enlarge it):

Then, under the header "SATA Configuration", I change IDE into AHCI Mode. Namely for SATA Mode.

Then, under the header "External SATA 6GB/s Configuration", I also change IDE into AHCI. Namely for External SATA 6gb/s Controller Mode.

See the image below (click on it to enlarge it):

Check for updated firmware

3. Check the website of the SSD manufacturer, whether there's an updated version available of the firmware for your SSD. If so, apply it.

For most SSD's it doesn't matter that you're running Linux, because many manufacturers offer such firmware updates by means of an iso file with which you can create a bootable DVD, much like you can do with an iso file of Linux Mint or Ubuntu.

In the first year after purchase, repeat this check every month or so.

Avoid quick wear: reduce write actions (within reason)

4. A Solid State Drive is worn down by write actions. Especially the oldest generations of SSD's were vulnerable in that aspect, but to a lesser degree that's still the case for the newer generations.

Below you'll find some tips on keeping wear down to a reasonable minimum, by limiting the write actions. Within reason, because a modern SSD is already pretty wear-resistant by default.

When you apply my tips, a lifespan of more than 10 years should be a normal expectation for your SSD. Which is considerably longer than the average lifespan of an old-fashioned platter disk.

Note: these directions are only meant for a Solid State Drive (SSD), not for an ordinary conventional spinning hard disk!

Nowadays unnecessary: overprovisioning

5. Over-provisioning (with or without a dash) is a technique that was widely used to improve the performance and life span of an SSD. I won't explain it here, but it boils down to not formatting a part of the SSD, which then remains unallocated space (unused capacity).

General opinion used to be, that it's wise to reserve as much as 28 percent of the storage capacity of an SSD for such unallocated space. That's of course a huge slice out of the total storage capacity, which makes nobody happy....

However, in the newer generations of SSD's the technology and firmware have improved so much, that such huge losses of storage capacity aren't needed any longer. Modern SSD's usually have some built-in unallocated space for overprovisioning anyway, which isn't accessible to the user.

So overprovisioning shouldn't be necessary anymore.

During installation: select EXT4

6. The best file system (formatting) for an SSD, is the usual default EXT4. So you don't have to choose anything different in this respect.

The journaling that comes with EXT4 causes some write activity, but not very much. Plus journaling is a very important feature for system crash recovery, so you don't want to disable it.

Note: don't select the BTRFS file system! Mainly because it's not as mature as EXT4 yet, but also because it might (under certain circumstances) cause more write actions than EXT4 does.

After the installation: noatime

7. With "noatime" in /etc/fstab, you disable the write action "access time stamp", that the operating system puts on a file whenever it's being read by the operating system. For an SSD "noatime" is better. This has hardly any negative side effect (only in rare use cases which most people won't ever encounter).

You can do that as follows:

a. Launch a terminal window.
(You can launch a terminal window like this: *Click*)

b. Then type in the terminal (use copy/paste):

xed admin:///etc/fstab

(Note: the three consecutive dashes aren't a typo, but intentional! For Ubuntu: type gedit instead of xed.)

Press Enter.

c. Now in that text file, add the word noatime to the line for your root partition and your other Linux partitions, just before errors=remount-ro. Use a comma as separator, no spaces.

Note: don't add it to the line for the swap file or partition (if you have one), nor to the line for the /boot/efi partition (if you have one), nor to the line for the /boot partition (if you have one)!

If you have other EXT4 partitions, you'll probably see defaults in their fstab line instead of errors=remount-ro. In that case, you put noatime just before defaults. Again, use a comma as separator, no spaces.

Here's an example of an adapted line for a root partition, in which you can see the exact spot where the noatime switch has to be put:

UUID=xxxxxxx / ext4 noatime,errors=remount-ro 0 1

And here's an example of an adapted line for another (non-root) partition, which in the example is mounted as /storage:

UUID=xxxxxxx /storage ext4 noatime,defaults 0 1

Note: there should be no space after the comma after noatime! Otherwise boot failure will probably occur. See the example lines above.

c. Save the modified text file and close it.

d. Now proceed to the next item.

Still relevant: select your TRIM method

8. The cleaning action TRIM is necessary for the good performance of your SSD in the long run. Otherwise it'll become very slow after some time.

All modern SSD's should support TRIM, but older SSD's from before 2010 usually don't. When in doubt, check it like this (example where your SSD is called sda by Linux):

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste):

sudo hdparm -I /dev/sda | grep TRIM

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

Your SSD supports TRIM when one of the messages you get, looks like this:

Data Set Management TRIM supported

It's easiest to let the system perform an automatic TRIM. That can be done in several ways.

In Linux Mint and Ubuntu automatic TRIM is enabled by default, when you install them on an SSD. Namely by a weekly "job".

But in many (most?) cases, once a week isn't often enough, so I advise you to read on.

Discouraged: by rc.local

8.1. You can add the TRIM command to /etc/rc.local. Then this command will be executed automatically on system boot. In the past, this was a good solution that hardly slowed the boot process down.

However, nowadays there's a new boot process called systemd. For systemd it may cause a huge boot delay (minutes!) when you put the fstrim command in /etc/rc.local. So that's why I don't recommend this method anymore.

Preferred method: daily job

8.2. Trimming daily is better than weekly, because then you don't have to wait so long before recoverable disk space becomes fully usable again.

You can schedule a daily trimming as follows.

a. Copy/paste the following command line into the terminal, in order to create a new folder:

sudo mkdir -v /etc/systemd/system/fstrim.timer.d

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

b. Copy/paste the following command line into the terminal, in order to create a new file in that new folder:

sudo touch /etc/systemd/system/fstrim.timer.d/override.conf

Press Enter.

c. Copy/paste the following command line into the terminal, in order to edit the new file:

xed admin:///etc/systemd/system/fstrim.timer.d/override.conf

(Note: the three consecutive dashes aren't a typo, but intentional! For Ubuntu: type gedit instead of xed.)

Press Enter.

d. Now copy/paste this blue text into that empty text document:

[Timer]
OnCalendar=
OnCalendar=daily


Note: the double entry for OnCalendar is no mistake but intentional!

e. Reboot your computer.

f. Confirm that you've successfully edited trim's configuration by executing this terminal command:

systemctl cat fstrim.timer

Your output should look like this:

# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

# /etc/systemd/system/fstrim.timer.d/override.conf
[Timer]
OnCalendar=
OnCalendar=daily


Let's take a look at this output. The first part shows the default setting (weekly), the second part shows the overriding setting that you've applied. That overriding setting contains two elements: first the existing OnCalendar setting (weekly) is being deleted, and then a new OnCalendar setting is being applied (daily).

If you ever want to check whether fstrim has actually happened, and when it happened, you can use this terminal command:

journalctl | grep fstrim

If you're done with this step, you can continue with item 9.

How to undo (back to a weekly job)

8.2.1. Want to undo? It's easy to change the daily job back to a weekly job, namely as follows.

a. Copy/paste the following command line into the terminal, in order to remove the overriding settings:

sudo rm -v /etc/systemd/system/fstrim.timer.d/override.conf

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

b. Reboot your computer.

Strongly discouraged: by discard

8.3. Unfortunately, another widely used method for automatic TRIM is to add the option discard to /etc/fstab, for the line for your root partition and for potential other Linux partitions in /etc/fstab. This is not a good method!

The disadvantage of the discard method is, that it'll regularly cause the system to slow down a lot. Because it forces the system to apply TRIM instantly on every file deletion. That's why I strongly discourage this method.

Now proceed to item 9.

How to execute TRIM manually

9. You can execute TRIM manually as well. You can use a single terminal command that will execute TRIM on all mounted partitions that support it:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste):

sudo fstrim -av

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

This operation may last for minutes; it then looks as if the terminal has frozen. That's not true, however; simply wait patiently....

Note: on a few SSD models (specifically two models from Crucial), executing this command when there's high disk activity (I/O activity), might cause problems. So only apply it when there's not much activity going on. Preferably with all other applications closed.

Now proceed to the next item.

Limiting swap wear

10. With the action described below, you limit the use of the swap file or partition (the virtual memory on the SSD). Without disabling it entirely, because that would go too far: in case of extreme RAM load, your Linux has to be able to "swap" to the hard disk.

Linux's inclination to use the swap, is determined by a setting called swappiness. The lower the setting number, the more system load is required before your Linux starts using the swap.

On a scale of 0-100, the default setting is 60. Which is much too high for normal desktop use, and only fit for servers. For SSD's, it's just crazy.

A detailed explanation can be found here (link dead? Then download this pdf file with the same content).

Now the how-to:

a. Check your current swappiness setting. Type in the terminal (use copy/paste):

cat /proc/sys/vm/swappiness

Press Enter.

The result will probably be 60.

b. Now type in the terminal (use copy/paste):

xed admin:///etc/sysctl.conf

Press Enter. (for Ubuntu: type gedit instead of xed)

c. Add the following blue lines, at the very end of the existing text in that file (use copy/paste to avoid errors):

# Sharply reduce the inclination to swap
vm.swappiness=1

d. Save the file and close it.

e. Now proceed to the next item.

Almost ready after reboot

11. Reboot your computer.

Your SSD is almost ready now, but not quite. So after the reboot, proceed to the next item.

Limiting the disk write actions of Firefox

12. You can limit the disk write actions of Firefox, by putting the Firefox network cache into the RAM and by disabling sessionstore. Like this:

Putting the Firefox network cache into the RAM

12.1. By moving the Firefox network cache from your hard disk to the RAM, you diminish the amount of disk writes. This'll probably make your Firefox noticeably faster as well. The price you pay is small: it'll only "cost" you 200 MB of your RAM.

Note: don't do this when your computer has less than 2 GB of RAM! Because with very little RAM, even 200 MB can't be missed.

Proceed like this:

a. Type in the URL bar of Firefox:
about:config
Press Enter.

b. Now you're being presented with a warning. Ignore it and click on the button "I accept the risk!".

c. Copy/paste the following into the filter bar (search bar):
browser.cache.disk.enable
Toggle its value to false by double-clicking it: this will disable "cache to disk" entirely.

d. Now you're going to make sure that "cache to RAM" is enabled. Copy/paste the following into the filter bar (search bar):
browser.cache.memory.enable
This should already be set to true; if not, toggle it to true by double-clicking it.

e. Then you're going to determine how much memory can be used as RAM cache. Copy/paste this into the filter bar (search bar):
browser.cache.memory.capacity
You'll probably won't find an existing instance. If (as expected) nothing was found, create it like this:

Right-click on the blank area in Firefox, then select New - Integer.
Make this the preference name:
browser.cache.memory.capacity
Enter the integer value in KB; I advise 204800 (which equals 200 MB). That's usually more than enough.

f. Close Firefox and launch it again. You're done! Check it like this:

Type in the URL bar:
about:cache
Press Enter.

By the way: you'll then also see a mention of an "appcache" which is still present on the disk, but there's no need to move that (much less frequently used) cache to the RAM as well.

Note: This is a user preference. Repeat this hack in each user account.

Disabling sessionstore

12.2. Firefox has a session restore feature, which remembers what pages were opened if Firefox experiences an unexpected shutdown (read: crashes). This feature is neat, but causes many disk writes. Too many for an SSD. Disable it like this:

a. Type in the URL bar of Firefox:

about:config

Press Enter.

b. Now you're being presented with a warning. Ignore it and click on the button "I accept the risk!".

c. Type in the filter bar: sessionstore

c. Double-click on the item called browser.sessionstore.interval. The default interval is 15000, which means 15 seconds. Add three zeros to the existing value, so that it becomes: 15000000 and click the OK button.

d. Close Firefox and launch it again. Now you've practically disabled the session restore feature.

Note (1): Leave the other cache and sessionstore settings as they are: usually, the less invasive a hack is, the better. Because this reduces the risk of unexpected unwanted side effects.

Note (2): This is a user preference. Repeat this hack in each user account.

Limiting the disk write actions of Chrome

13. The disk write actions of Google Chrome can be limited as follows.

a. Click on the three dots (vertical line) in the upper right of the Chrome window - Settings. Down below, click on Advanced.

Section Privacy: remove the tick for:
Use a prediction service to load pages more quickly

Close Chrome and launch it again.

This way, you've disabled the "preload" feature, which can cause a lot of extra web traffic and also a lot of writes.

Now proceed to the next item.

Set the scheduler to NOOP

14. By default, Ubuntu and Linux Mint use the I/O scheduler CFQ, which is good for conventional platter hard disks, but not optimal for SSD's. So if you have only SSD's to deal with, it's better to change that scheduler into NOOP, which is optimal for SSD performance.

You can check your current scheduler as follows: use copy/paste to transfer the following blue command line to the terminal:

cat /sys/block/sda/queue/scheduler

(if your drive isn't sda, change the line accordingly)

Press Enter.

The output will probably be:

noop deadline [cfq]

Which means: CFQ is active (because it's between brackets), but NOOP and Deadline are also supported. Change it as follows into NOOP, which optimizes SSD performance:

a. Type in the terminal (use copy/paste):

xed admin:///etc/default/grub

Press Enter. (for Ubuntu: type gedit instead of xed)

Find this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

And replace it by this line:

GRUB_CMDLINE_LINUX_DEFAULT="elevator=noop quiet splash"

b. Save the modified file and close it.

c. Now update Grub for this change. In the terminal (use copy/paste):

sudo update-grub

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

e. Reboot your computer.

f. Proceed to the next item.

Do NOT enable hibernation

15. Hibernation (suspend-to-disk) causes a huge amount of write actions, which is bad for an SSD. In Linux Mint and Ubuntu, it's disabled by default. Don't enable it! (item 10).

Also for an SSD: prevent fragmentation, and DO NOT defrag

16. For an SSD, fragmentation of the file system is a smaller problem than for ordinary rotating hard disks. But it's nevertheless still a problem, so it's useful to prevent fragmentation as much as possible on an SSD, too. You can achieve that by preserving a minimum of 20 % free space on each partition (item 4).

Prevention is all the more important, as defragmenting is out of the question anyway: your SSD would wear rapidly, because of the many write actions it causes.

The reason that fragmentation is also a problem for an SSD, is this:

The mechanical seek time of an SSD is always 0, regardless of the fragmentation. That's a big difference with rotating hard disks, on which the seek time increases as fragmentation grows. This disappearance of mechanical seek time is a significant improvement.

But mechanical seek time only makes up a part of total access time, or I/O time, of any single input/output request made to the disk.

I/O time is the time a computer system takes to complete a request cycle. All the way from application, operating system and driver down to disk hardware, memory cells, and then back again.

Zero mechanical seek time certainly does not mean zero I/O time. No matter how fast an SSD is, its I/O time can never be zero. File system fragmentation increases I/O time in an SSD, even when the mechanical seek time is zero.

To put it another way: the performance degradation as a result of fragmentation is not caused by the storage device alone (whether there's a mechanical moving part or not), but it's also a problem concerning the system as a whole.

The task for the system becomes heavier, when there are more files to be chopped up and more pieces of files to be glued together. The heavier the task, the longer the processing time.

A good and elaborate explanation of this fact can be found in this pdf file.

Dual boot or Virtual Machine? Don't let Windows kill your SSD

17. Do you have a dual boot with Windows? Then don't let Windows kill your SSD by defragmenting it: disable scheduled automatic defragmentation.

Defragmentation will kill your SSD in a very short time, because of the multitude of write actions that it causes. Windows should recognize an SSD by itself and then refrain from automatic defragmenting, but this SSD recognition has been known to fail in several cases. So make 100 % sure that Windows doesn't defragment your SSD automatically, by disabling that feature. Also in a Virtual Machine with Windows!

Within Linux you don't have this problem, because Linux filesystems hardly fragment in the first place and so don't need to be defragmented anyway.

Enjoy your SSD carefree for years and years

18. Now you'll be able to enjoy your SSD carefree!

As already said in the start of this how-to: taking into account the long warranty periods that the manufacturers are giving, your SSD will probably last for more than five years (10 years should be a reasonable expectation).

Considerably longer than an ordinary platter hard disk generally lasts, anyway...

Want more tips?

19. Do you want more tips and tweaks? There's a lot more of them on this website!

For example:

Speed up your Linux Mint!

Clean your Linux Mint safely

Avoid 10 fatal mistakes


To the content of this website applies a Creative Commons license.

Back to the home page

Disclaimer