Optimize SSD's for Longer Lifespan

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
dark
Level 3
Level 3
Posts: 120
Joined: Wed Feb 22, 2017 3:02 pm

Optimize SSD's for Longer Lifespan

Post by dark » Thu Nov 08, 2018 7:21 am

Step 0:
sudo apt install util-linux
Most distros has this package installed OOTB so you can skip this step.

Step 1:
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer
Configured OOTB in Linux Mint so you can skip this step.

Step 2:
xed admin:///etc/fstab
Add noatime mount option.
Noatime mount option fully disables writing file access times to SSD every time you read a file, this reduces the writes to SSD therefore greatly increasing lifespan of SSD’s.
Add noatime mount option to all partitions except swap partition.
Image

Step 3:
xed admin:///etc/sysctl.conf
Add vm.swappiness=10
So writing to swapfile/swap partition only occurs after RAM is filled 90% instead of default 60%. Good if you do lot of web browsing, video editing and gaming and do not want contents of RAM frequently written to swapfile/swap partition on SSD after RAM is filled only 60%.
Image

Step 4:
Enable write cache from Gnome Disks.
Image

User avatar
xenopeek
Level 24
Level 24
Posts: 23128
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Optimize SSD's for Longer Lifespan

Post by xenopeek » Thu Nov 08, 2018 8:05 am

dark wrote:
Thu Nov 08, 2018 7:21 am
Step 2:
sudo xed /etc/fstab
Add noatime mount option.
Noatime mount option fully disables writing file access times to SSD every time you read a file, this reduces the writes to SSD therefore greatly increasing lifespan of SSD’s.
Add noatime mount option to all partitions except swap partition.
That's a great exaggeration. Linux Mint by default uses relatime, which only updates access time if the file is being modified (and thus the file information block would be rewritten anyway) or the previous access time is older than 1 day.

Adding noatime leads to an insignificant difference in lifespan.
Image

dark
Level 3
Level 3
Posts: 120
Joined: Wed Feb 22, 2017 3:02 pm

Re: Optimize SSD's for Longer Lifespan

Post by dark » Thu Nov 08, 2018 10:10 am

I didn't know about Linux Mint using relatime by default.

User avatar
Pjotr
Level 20
Level 20
Posts: 10985
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Thu Nov 08, 2018 10:26 am

Don't use sudo xed, but xed admin:// instead.
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

User avatar
xenopeek
Level 24
Level 24
Posts: 23128
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Optimize SSD's for Longer Lifespan

Post by xenopeek » Thu Nov 08, 2018 10:55 am

Good catch. I've updated it in OP's post.
Image

gm10
Level 12
Level 12
Posts: 4170
Joined: Thu Jun 21, 2018 5:11 pm

Re: Optimize SSD's for Longer Lifespan

Post by gm10 » Thu Nov 08, 2018 11:27 am

dark wrote:
Thu Nov 08, 2018 7:21 am
Add vm.swappiness=10
So writing to swapfile/swap partition only occurs after RAM is filled 90% instead of default 60%. Good if you do lot of web browsing, video editing and gaming and do not want contents of RAM frequently written to swapfile/swap partition on SSD after RAM is filled only 60%.
That parameter does not define a free RAM percentage (check the kernel sources, that parameter is used as part of a number of formulas, but none of them are about what you claim). If you decrease this value you'll probably see less caching and thus have a good chance of more disk activity, both depending on your use case.
dark wrote:
Thu Nov 08, 2018 7:21 am
Enable write cache from Gnome Disks.
Write caching is enabled by default.

User avatar
Pjotr
Level 20
Level 20
Posts: 10985
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Thu Nov 08, 2018 1:05 pm

gm10 wrote:
Thu Nov 08, 2018 11:27 am
That parameter does not define a free RAM percentage (check the kernel sources, that parameter is used as part of a number of formulas, but none of them are about what you claim). If you decrease this value you'll probably see less caching and thus have a good chance of more disk activity, both depending on your use case.
This is a good article in the wiki of Arch Linux (which is almost always a great resource), about the effects of swappiness reduction:
https://wiki.archlinux.org/index.php/Swap#Swappiness

The article it refers to is worth reading as well:
http://rudd-o.com/en/linux-and-free-sof ... o-fix-that
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

gm10
Level 12
Level 12
Posts: 4170
Joined: Thu Jun 21, 2018 5:11 pm

Re: Optimize SSD's for Longer Lifespan

Post by gm10 » Thu Nov 08, 2018 2:13 pm

Pjotr wrote:
Thu Nov 08, 2018 1:05 pm
The article it refers to is worth reading as well:
http://rudd-o.com/en/linux-and-free-sof ... o-fix-that
He wrote 11 years ago, when the kernel's paging strategy was different:
On a desktop computer, you want swappiness to be as close to zero as possible. The reason you want to do this (even though it might hurt actual performance) is because this will immunize your computer to memory shortages caused by temporary big file manipulations (think copying a big video file to another disk).
Do try this with a present day kernel. He even provides a test script. I think you'll find it doesn't behave the way he experienced it back then, I know it doesn't on my laptop at least. That aside very nice article.
Last edited by gm10 on Thu Nov 08, 2018 3:02 pm, edited 2 times in total.

User avatar
Pjotr
Level 20
Level 20
Posts: 10985
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Thu Nov 08, 2018 2:21 pm

gm10 wrote:
Thu Nov 08, 2018 2:13 pm
Pjotr wrote:
Thu Nov 08, 2018 1:05 pm
The article it refers to is worth reading as well:
http://rudd-o.com/en/linux-and-free-sof ... o-fix-that
He wrote 11 years ago
Last modified five years ago, so that makes it less ancient....
gm10 wrote:
Thu Nov 08, 2018 2:13 pm
, when the kernel's paging strategy was different:

Code: Select all

On a desktop computer, you want swappiness to be as close to zero as possible. The reason you want to do this (even though it might hurt actual performance) is because this will immunize your computer to memory shortages caused by temporary big file manipulations (think copying a big video file to another disk). 
To try this with a present day kernel. He even provides a test script. I think you'll find it doesn't behave the way he experienced it back then, I know it doesn't on my laptop at least. That aside very nice article.
Can you perhaps give some links that elaborate on this change of the kernel's paging strategy?
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

User avatar
thx-1138
Level 6
Level 6
Posts: 1251
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: Optimize SSD's for Longer Lifespan

Post by thx-1138 » Thu Nov 08, 2018 2:28 pm

...at least on my own laptop, i do find that the default value of 60 makes it crawl from time to time (also, article is last modified June 2013).

My question though would be different:
exactly what do people do in their 'desktop' to somehow need to achieve a longer SSD lifespan?
Pretty much every 'scientific' & reliable article i've read about SSDs refers to...numerous decades of lifespan -
unless of course it borks out of the blue one morning, which can happen with any digital device.

I can understand concerns for such if someone runs a database with thousands of writes per hour,
or maybe if someone has turned his/her machine to a dedicated 24/7 torrents' seedbox with tons of HD rips... :)
But for common installations?...

gm10
Level 12
Level 12
Posts: 4170
Joined: Thu Jun 21, 2018 5:11 pm

Re: Optimize SSD's for Longer Lifespan

Post by gm10 » Thu Nov 08, 2018 2:41 pm

Pjotr wrote:
Thu Nov 08, 2018 2:21 pm
Can you perhaps give some links that elaborate on this change of the kernel's paging strategy?
I tried to google something but it's surprisingly hard to find something on the evolution of this. Here's 2 write-ups about changes done back in the 2.6 series:
https://www.kernel.org/doc/gorman/html/ ... html#toc27
https://linux-mm.org/PageReplacementDesign
Also ancient but still more recent than 11 years ago.

User avatar
thx-1138
Level 6
Level 6
Posts: 1251
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: Optimize SSD's for Longer Lifespan

Post by thx-1138 » Thu Nov 08, 2018 2:56 pm

...the swappiness value has been debated way too frequently in those forums here -
which is also something i don't really understand as to why it should somehow be controversial, especially since...

Edit: also from Red Hat...a simplified explanation of how swappiness gets calculated...

...all in all, i believe that SSDs are configured pretty reasonably out-of-the-box for 'desktops',
and as for swappiness, it you experience slow-downs with 60, just set it to something lower, yet without overdoing such...

User avatar
Pjotr
Level 20
Level 20
Posts: 10985
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Fri Nov 09, 2018 5:22 am

thx-1138 wrote:
Thu Nov 08, 2018 2:56 pm
...the swappiness value has been debated way too frequently in those forums here -
which is also something i don't really understand as to why it should somehow be controversial, especially since...

Edit: also from Red Hat...a simplified explanation of how swappiness gets calculated...
Excellent information! Thanks.

More elaborate than the Arch wiki, yet simplified enough to be understandable for me. :mrgreen:

On my machines, I keep track of swap use by means of Conky:
https://sites.google.com/site/easylinux ... forxubuntu

I usually apply a swappiness of 10 for HDD's and 1 for SSD's. On one machine with an SSD and little RAM (2 GB) I even had to set swappiness to 0, in order to prevent frequent use of the swap....
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Post Reply

Return to “Tutorials”