Contents of this page:

General advice: avoid exaggeration

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

Advanced

Integrated Peripherals

Check for updated firmware

Avoid quick wear: reduce write actions

During installation: select EXT4

Set the automatic TRIM job to daily

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

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

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

gedit

xed

[Timer]

OnCalendar=

OnCalendar=daily

OnCalendar

systemctl cat fstrim.timer

# /lib/systemd/system/fstrim.timer

[Unit]

Description=Discard unused blocks once a week

Documentation=man:fstrim

ConditionVirtualization=!container



[Timer]

OnCalendar=weekly

AccuracySec=1h

Persistent=true



[Install]

WantedBy=timers.target



# /etc/systemd/system/fstrim.timer.d/override.conf

[Timer]

OnCalendar=

OnCalendar=daily

journalctl | grep fstrim.service

How to undo (back to a weekly job)

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

How to execute TRIM manually

sudo fstrim -av

-av

sudo fstrim -v /

Limiting swap wear

cat /proc/sys/vm/swappiness

xed admin:///etc/sysctl.conf

gedit

xed

# Reduce the inclination to swap

vm.swappiness=20

Limiting the disk write actions of Firefox

Putting the Firefox network cache into the RAM

about:config

browser.cache.disk.enable

false

browser.cache.memory.enable

true

true

browser.cache.memory.capacity

-1

307200

about:cache

Disabling sessionstore

about:config

sessionstore

browser.sessionstore.interval

15000

15000000

Limiting the disk write actions of Chrome

Privacy and security

Preload pages for faster browsing and searching

Some SSD's: set the scheduler to NOOP

cat /sys/block/sda/queue/scheduler

sda

[mq-deadline] none

noop deadline [cfq]

xed admin:///etc/default/grub

gedit

xed

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

GRUB_CMDLINE_LINUX_DEFAULT="elevator=noop quiet splash"

sudo update-grub

Optional: set noatime

sudo sed -i 's/ errors=remount-ro/ noatime,errors=remount-ro/' /etc/fstab

sudo sed -i 's/ defaults/ noatime,defaults/' /etc/fstab

Prevent fragmentation, and DO NOT defrag

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

Enjoy your SSD carefree for years and years

Five pitfalls concerning SSD's

Unnecessary: alignment

Unnecessary: overprovisioning

Strongly discouraged: TRIM by rc.local

/etc/rc.local

systemd

/etc/rc.local

Strongly discouraged: TRIM by discard

discard

Strongly discouraged: hibernation

Want more tips?

Below you'll find a complete how-to for optimizing your SSD for Linux Mint 20 and for Ubuntu 20.04. So that you'll be able to enjoy your SSD for many years!1. First a word of caution: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 a spinning platter hard disk, anyway...Below I'll start by mentioning the things I recommend to do. The things that I warn against, are described after that.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). On modern computers AHCI is the default, so that's fine. But on older machines the default might be 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 an older 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 that older computer is, by the way, an MSI H61MA-E35 (B3).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, and there I expand the section(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):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.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 (much) lesser degree that's still the case for the newer SSD 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 spinning platter disk.5. 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.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.6. The cleaning action TRIM is recommended for the good performance of your SSD in the long run. Otherwise it might become slow after some time.That's even true for new SSD's: although new SSD's nowadays usually have some form of garbage collection integrated into their firmware, it's always better to execute a regular TRIM as well.very old SSD's from before 2010 usually don't support TRIM.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 frequent enough: waiting an entire week before recoverable disk space becomes usable again, is simply too long.You can switch your system to automatictrimming as follows:a. Copy/paste the following command line into the terminal, in order to create a new folder:Press Enter. Type your password when prompted.Press Enter again.b. Copy/paste the following command line into the terminal, in order to create a new file in that new folder:Press Enter.c. Copy/paste the following command line into the terminal, in order to edit the new file:the three consecutive dashes aren't a typo, but intentional! For Ubuntu: typeinstead of.)Press Enter.d. Now copy/paste this blue text into that empty text document:the double entry foris no mistake but intentional!Save the modified file and close it.e. Reboot your computer.f. Confirm that you've successfully edited trim's configuration by executing this terminal command:Your output should look approximately like this: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:If you're done with this step, you can continue with item 8.6.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:Press Enter. Type your password when prompted.Press Enter again.b. Reboot your computer.7. 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.Type ( use copy/paste ):Press Enter. Type your password when prompted.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....it's possible that manually executing fstrim withdoesn't work. In that case, use this command:on a few SSD models (specifically two models from Crucial), executing a manual fstrim 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.8. 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 very heavy 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. For SSD's, it also causes too many disk writes.This is the how-to for decreasing the swappiness to a more reasonable level:a. Check your current swappiness setting. Type in the terminal ( use copy/paste ):Press Enter.The result will probably be 60.b. Now type in the terminal ( use copy/paste ):Press Enter.c. Add the following blue lines, at the very end of the existing text in that file ( use copy/paste to avoid errors):d. Save the file and close it.e. Reboot your computer. Then proceed to the next item.9. You can limit the disk write actions of Firefox, by putting the Firefox network cache into the RAM and by disabling sessionstore. Like this:9.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 300 MB of your RAM.don't do this when your computer has only 2 GB of RAM or less! Because with very little RAM, even 300 MB can't be missed.Proceed like this:a. Type in the URL bar of Firefox: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):Toggle its value toby double-clicking it: this will disable "cache to disk" entirely.d. Now you're going to make sure that "cache to RAM" is enabled (it is by default, but it may have been changed earlier). Copy/paste the following into the filter bar (search bar):This should already be set to; if not, toggle it toby 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):The currentwill probably be, which automates the size of the RAM cache dependent on the amount of RAM. Set it to(the figure indicates KB, which equals 300 MB). That's usually enough for all amounts of RAM.f. Close Firefox and launch it again. You're done! Check it like this:Type in the URL bar: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 absolutely no need to move that (much less frequently used) cache to the RAM as well.This is a user preference. Repeat this hack in each user account.9.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: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:c. Double-click on the item called. The default interval is, which means 15 seconds. Add three zeros to the existing value, so that it becomes:and click the OK button.d. Close Firefox and launch it again. Now you've practically disabled the session restore feature.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.This is a user preference. Repeat this hack in each user account.10. 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.Section- Cookies and site data: disable it.Close Chrome and launch it again.This way, you've disabled the "preload" feature, which can cause a lot of extra network traffic and also a lot of writes.Now proceed to the next item.11. By default, Ubuntu and Linux Mint use the I/O scheduler CFQ for some SSD's. Which is good for conventional platter hard disks, but not optimal for SSD's. So if you have only SSD's to deal with, which have the CFQ setting, it's better to change that scheduler into NOOP. Because that's 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:(if your drive isn't, change the line accordingly)Press Enter.For some SSD's, the output will be:In that case you don't need to do anything; the scheduler setting is already optimal for your device.But for other SSD's the output will be: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):Press Enter.Find this line:And replace it by this line:b. Save the modified file and close it.c. Now update Grub for this change. In the terminal (use copy/paste):Press Enter. Type your password when prompted.Press Enter again.e. Reboot your computer.f. Proceed to the next item.12. By setting "noatime", you disable the "access time stamp", that the operating system puts on a file whenever it's being read by the operating system. For an SSD "noatime" might be better, because it reduces the disk writes somewhat.Although noatime doesn't make a big difference (which is why setting it has been labeled as optional), it has hardly any negative side effects: only in very rare use cases which almost nobody will ever encounter.The easiest way to set noatime for your SSD, is this:a. Launch a terminal window.b. Then use copy/paste for transferring the following line into the terminal (don't try to type it: a typo can have serious consequences!):Press Enter. Type your password when prompted.Press Enter again.Do you have a separate partition for /home? Then you need to execute this command as well (use copy/paste, don't type):13. 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 14. 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.15. 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...For the sake of completeness I mention below some (unfortunately) popular misconceptions about tuning SSD's:16.1. A common misunderstanding is, that the partitions on the SSD should be properly aligned first. That used to be true many years ago, but no longer.In all 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.16.2. Over-provisioning (with or without a dash) is an outdated 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 toformatting a considerable part of the SSD, which then remains unallocated space (unused capacity).That outdated method took a sizeable slice out of the total storage capacity, which made nobody happy....However, in the newer generations of SSD's (let's say since about 2014) 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.16.3. You can also add the TRIM command to. Then this command will be executed automatically on system boot. Years ago, this was a good solution that hardly slowed the boot process down.However, things have changed: nowadays there's a boot process called. For systemd it may cause a huge boot delay (minutes!) when you put the fstrim command in. So that's why I strongly discourage this method.16.4. Unfortunately, another widely used method for automatic TRIM is to add the optionto the partition lines in /etc/fstab. This is a heavily exaggerated measure with a high performance toll, and therefore not a good method!The disadvantage of the discard method is namely, that it might regularly cause the system to slow down. Because it forces the system to apply TRIM instantly on, which is resource-intensive, exaggerated and quite unnecessary. That's why I strongly discourage this method.16.5. 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!17. Do you want more tips and tweaks? There's a lot more of them on this website!For example: