SSD: how to optimize your Solid State Drive for openSUSE


Back to the home page


Below you'll find a complete how-to for optimizing your SSD for openSUSE. So that you'll be able to enjoy your SSD for many years!

Note: this how-to is only for openSUSE; the how-to for Ubuntu, Linux Mint and Debian is on another 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 sensibly.

This how-to will 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...

BIOS and UEFI: set it to AHCI

2. A Solid State Disk, or rather Drive (SSD), is sometimes only recognized properly by the BIOS or UEFI, when in the BIOS 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 the BIOS (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? Then the BIOS will possibly detect the SSD automatically and automatically choose 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):

https://sites.google.com/site/easylinuxtipsproject/ssd-in-opensuse/SSD-BIOS-1.JPG?attredirects=0

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):

https://sites.google.com/site/easylinuxtipsproject/ssd-in-opensuse/BIOS-SSD-3.JPG?attredirects=0

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 with which you can create a bootable CD.

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

Avoid quick wear: reduce write actions

4. A Solid State Drive is worn down relatively quickly 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 minimum, by limiting the write actions to a reasonable extent.

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

Reserve seven percent for overprovisioning

5. Over-provisioning (with or without a dash) is a technique that's being 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 20 to 25 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 anymore. Not for normal use, anyway.

But still I advise to reserve about seven percent for unallocated space. For normal use, that's a reasonable minimum.

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

https://sites.google.com/site/easylinuxtipsproject/ssd-in-opensuse/Screenshot-SSD-overprovisioning-5.jpg?attredirects=0

During installation: select EXT4

6. The best file system (formatting) for an SSD, is EXT4.

In EXT4, Linux writes every few seconds a journal to the hard disk, containing the whereabouts of the files. That causes some writing activity, but not much.

This feature is very important for recovery after a system crash. So it's best to keep it enabled.

Warning: do not select BTRFS! In openSUSE 13.2 BTRFS is the default file system during the installation, so be careful to change that.

BTRFS causes a lot of write actions, because of the snapshots that Snapper makes of your system. That's not good for an SSD....

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 much better.

You can do that as follows:

a. If not done before: first install text editor Leafpad.

b. Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/fstab

Press Enter.

c. Now add "noatime" to the line for your root partition and your other Linux partitions. Not to the line for the swap partition!

An adapted line may look like this:
/dev/disk/by-id/xxxxx   /    ext4     noatime,acl,user_xattr     1 1

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

d. Save the modified text file and close it.

e. Now proceed to the next item.

Automatic TRIM: by boot.local, by cron or by discard

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 support TRIM, but older SSD's from before 2010 usually don't. So for an older SSD you'll want to check this on the website of the manufacturer.

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

Preferred method: by boot.local

8.1. You can add the TRIM command to /etc/rc.d/boot.local. Then this command will be executed automatically on system boot. This hardly slows the boot process down. This is the method that I prefer.

You can do that as follows:

a. If not done before: first install text editor Leafpad.

b. Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/rc.d/boot.local

Press Enter.

c. At the last line of the text in that file, you now add the TRIM command
fstrim -v for every automatically mounted EXT4 partition.

Note:
not for partitions that aren't mounted by default! And also not for the swap partition, as that's already being trimmed automatically by the system by default, during the boot process.

An example is most clarifying. When your Linux is on one single partition, so you have only the root partition / , then your rc.local should look like this:

#! /bin/sh
#
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.  All rights reserved.
#
# Author: Werner Fink, 1996
#         Burchard Steinbild, 1996
#
# /etc/init.d/boot.local
#
# script with local commands to be executed from init on system startup
#
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#
fstrim /

If you have a separate home partition (although that's not very useful), then you add the following line as well:
fstrim /home

Note: if you have a separate partition for /boot/efi, don't add a line for that. It's useless, as that partition is seldom being written to. And it may even cause malfunctions.

d. Save the modified file and close it.

e. Reboot your computer.

f. Now proceed to item 9 (right column).

Computers that are always on: by cron

8.2. For computers that are always on (24 hours a day, seven days a week), a TRIM action that's being executed when booting, is of course not useful. In such a case you're better off with a "timer", i.e. with cron.

You can do that as follows:

a. If not done before: first install text editor Leafpad.

b. Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/cron.daily/trim

Press Enter.

c. Copy/paste the following text in that empty text file:
#!/bin/sh
fstrim /


Note: if you have a separate home partition (although that's not very useful), use the following text instead:
#!/bin/sh
fstrim / && fstrim /home


Note: if you have a separate partition for /boot/efi, don't add a trim command for that. It's useless, as that partition is seldom being written to. And it may even cause malfunctions.

Save the text file.

d. Now copy/paste the following command into the terminal, in order to render the file executable:
chmod +x /etc/cron.daily/trim

Press Enter. Type your password when prompted; this remains entirely invisible, not even dots will show, this is normal. Press Enter again.

e. Reboot your computer.

openSUSE will now perform the daily cron job automatically, at 06:25, or (when the computer isn't on at that time), automatically at a later time on the same day.

f. Now proceed to item 9 (right column).

(continued in the column on the right)


This website is being sponsored by Google Ads.

Are you using an ad blocker? Then you're also blocking my earnings from advertisements....

If you wish to support my website, you can configure your ad blocker to make an exception for this website. Or you can make a donation (and get free goodies).

Thanks in advance....


Not advised: by discard

8.3. Another widely used method for automatic TRIM is to add the option discard to /etc/fstab, to the line(s) for your root partition and for possible other Linux partitions that are being mentioned there.

Note:
do not add it to the line for the swap partition, as that's already being trimmed automatically by the system by default, during the boot process!

The disadvantage of this method is, that it may cause the system to slow down. Because it forces the system to apply TRIM instantly on every file deletion. That's why this method is not my favourite.

If you want to do it anyway, then this is how:

a. If not done before: first install text editor Leafpad.

b. Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/fstab

Press Enter.

c. Now add "discard" to the line for your root partition and for your other Linux partitions that are being mentioned in this file. Not to the line for the swap partition!

An adapted line may look like this:
/dev/disk/by-id/ata-WDC_WD2500BEVT-22A23T0_WD-WX61C50H7642-part6 /                    ext4       discard,noatime,acl,user_xattr        1 1

Note: if you have a separate partition for /boot/efi, don't add a trim command for that. It's useless, as that partition is seldom being written to. And it may even cause malfunctions.

d. Save the modified text file and close it.

e. Reboot your computer.

f. Now proceed to item 9.

Note: as already mentioned, old SSD's made before 2010 usually don't support TRIM. In that case, do not apply the option discard in fstab.

How to execute TRIM manually

9. You can execute TRIM manually as well, namely as follows:

Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Type:
su -
Press Enter

Type (use copy/paste):
fstrim -v /

Press Enter. Type your password when prompted; this remains entirely invisible, not even dots will show, this is normal. 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....

The above terminal command is enough when you have only one Ubuntu partition and a swap partition (because for the swap it's unnecessary; the system takes care of that automatically).

When you have more mounted EXT4 partitions, you'll have to adapt the command line accordingly. For example, if you have a separate home partition (although that's not very useful), then the command is:
fstrim -v /home

Now proceed to the next item.

Limit swap wear

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

If not done before: first install text editor Leafpad.

a. Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Check the current swappiness. Type:
cat /proc/sys/vm/swappiness

The output is probably 60, which is far too high a number. Even for conventional hard disks (with the exception of servers), let alone for SSD's.... So reduce it to 1 as follows:

Type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/sysctl.conf

Press Enter.

b. Add the following blue lines, at the very end of the existing text in that file (use copy/paste to avoid errors):
# Sharply reduce swap inclination
vm.swappiness=1

c. Save the file and close it.

d. 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.

Limit the write actions of Firefox

12. You can limit the write actions of Firefox as follows.

a. Set the cache to 0:
Firefox menu button (with the three dashes on it) - Preferences - Advanced
Tab Network
section Cached Web Content: tick Override automatic cache management and set the cache to 0 MB.

b. If you have installed Oracle Java, limit the write actions of the Java plugin:
launch the Java Control Panel - Tab General:
Temporary Internet Files - Settings...
Remove the tick for: Keep temporary files on my computer.

Limit the write actions of Chrome and Chromium

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

- Launch Chrome / Chromium.

- Now tap the F12 key, in order to open the developers' console. Then tap the F1 key, in order to open the settings.

In the settings window you tick: Disable cache (while DevTools is open).

Unfortunately, this only works when the developers' console is open.... A workaround might be, to always open one extra tab in which you keep the developers' console opened. This should also have effect on the other, "normal" tabs.

Another possibility is, to launch Chrome from the terminal with the following command:

google-chrome --disk-cache-size=1 --media-cache-size=1

For Chromium the command is:

chromium-browser --disk-cache-size=1 --media-cache-size=1

Note: a value of 0 has no effect! But 1 byte should be satisfactory as well....

Now proceed to the next item.

Change the I/O scheduler to deadline

14. By default, openSUSE still uses the "old" I/O scheduler CFQ, which is only fine for conventional hard disks but not for SSD's, which are being slowed down. So it's wise when you have an SSD in your machine, to change the scheduler to Deadline, which is good for both SSD's and conventional platter hard disks.

You can realize this by changing the boot parameters of Grub. You can do that as follows.

If not done before: first install text editor Leafpad.

Open a terminal window (in Xfce: Menu button - System - Xfce Terminal).
Check your current scheduler as follows (use copy/paste to transfer the 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, but noop and deadline are also supported.

Now type:
su -
Press Enter

Type (use copy/paste):
leafpad /etc/default/grub

Press Enter.

Find the line: GRUB_CMDLINE_LINUX_DEFAULT= (...etc). This line may look like this (example):
GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/disk/by-id/ata-WDC_WD2500BEVT-22A23T0_WD-WX61C50H7642-part5 splash=silent quiet showopts"

And add the option elevator=deadline. Example:
GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/disk/by-id/ata-WDC_WD2500BEVT-22A23T0_WD-WX61C50H7642-part5 splash=silent quiet showopts elevator=deadline"

Save the modified file and close it.

Now update Grub for this change. In the terminal (use copy/paste):
grub2-mkconfig -o /boot/grub2/grub.cfg

Press Enter. Type your password when prompted; this remains entirely invisible, not even dots will show, this is normal. Press Enter again.

Reboot your computer.

Proceed to the next item.

Disable hibernation

15. Hibernation causes a huge amount of write actions, which is very bad for an SSD. Make sure it's disabled, by removing the package pm-utils. This you can do by using Install/Remove Software.

Also for an SSD: prevent fragmentation

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 on an SSD. You can achieve that by preserving a minimum of 20 % free space on each partition.

How does it work for an SSD?

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 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.

An elaborate explanation of this fact can be found here. Website down? Here's a pdf file.

Dual boot? 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.

Defragmentation will kill your SSD in a very short time, because of the multitude of write actions that it causes.

Within Linux you don't have this problem, because Linux doesn't fragment in the first place and so doesn't need to be defragmented at all.

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 for Linux? There's a lot more of them on this website! Like these:

Four popular myths and 11 tips about wireless security (for wifi)

Firefox: tweak it right

Chrome and Chromium: make them even better

Libre Office: configure it well


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


Comments