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: 124
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: 23719
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: 124
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: 11977
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.1 Tessa
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: 23719
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 16
Level 16
Posts: 6258
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: 11977
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.1 Tessa
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

gm10
Level 16
Level 16
Posts: 6258
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: 11977
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.1 Tessa
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 7
Level 7
Posts: 1624
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 16
Level 16
Posts: 6258
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 7
Level 7
Posts: 1624
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: 11977
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.1 Tessa
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

scjet45
Level 3
Level 3
Posts: 112
Joined: Sat May 07, 2016 12:50 am

Re: Optimize SSD's for Longer Lifespan

Post by scjet45 » Mon Mar 11, 2019 4:31 pm

Pjotr wrote:
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....
hey Hi @Pjotr.
I noticed that on your older https://sites.google.com/site/easylinux ... forxubuntu I'm getting a 404 error nowadays. ?
Is this: https://easylinuxtipsproject.blogspot.com/p/1.html your new tutroial tipsntricks for LinuxMint?
Anyway, your older tips for LinuxMint on sites.google.com was a very handy site for me.
Just wanna say a big thanks for all that too, meaning, I hope you keep it up.
:)

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

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Mon Mar 11, 2019 5:34 pm

scjet45 wrote:
Mon Mar 11, 2019 4:31 pm
hey Hi @Pjotr.
I noticed that on your older https://sites.google.com/site/easylinux ... forxubuntu I'm getting a 404 error nowadays. ?
Is this: https://easylinuxtipsproject.blogspot.com your new tutorial tipsntricks for LinuxMint?
Yes. :)

Everything has been moved to my new site, so no information has been lost.
Tip: 10 things to do after installing Linux Mint 19.1 Tessa
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Volvic
Level 1
Level 1
Posts: 6
Joined: Thu Mar 14, 2019 11:08 am

Re: Optimize SSD's for Longer Lifespan

Post by Volvic » Thu Mar 14, 2019 11:51 am

Step 2 and Stuck
any help please

Code: Select all

-System-Product-Name:~$ sudo systemctl start fstrim.timer
[sudo] password for toolbox:    
-System-Product-Name:~$ xed admin:///etc/fstab

** (xed:13543): WARNING **: 16:46:35.161: The specified location is not mounted

(xed:13543): Gdk-CRITICAL **: 16:46:35.163: gdk_window_get_window_type: assertion 'GDK_IS_WINDOW (window)' failed



Code: Select all

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/mint--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/nvme0n1p1 during installation
UUID=aec55987-0ef2-463b-9776-ca74fbb2f82b /boot           ext4    defaults        0       2
#/dev/mapper/mint--vg-swap_1 none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0
Thanks

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

Re: Optimize SSD's for Longer Lifespan

Post by Pjotr » Thu Mar 14, 2019 12:35 pm

Volvic wrote:
Thu Mar 14, 2019 11:51 am
Step 2 and Stuck
any help please
In your case, only add noatime to the root partition:

Code: Select all

/dev/mapper/mint--vg-root /               ext4    noatime,errors=remount-ro 0       1
Tip: 10 things to do after installing Linux Mint 19.1 Tessa
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Volvic
Level 1
Level 1
Posts: 6
Joined: Thu Mar 14, 2019 11:08 am

Re: Optimize SSD's for Longer Lifespan

Post by Volvic » Fri Mar 15, 2019 1:27 pm

Pjotr wrote:
Thu Mar 14, 2019 12:35 pm
Volvic wrote:
Thu Mar 14, 2019 11:51 am
Step 2 and Stuck
any help please
In your case, only add noatime to the root partition:

Code: Select all

/dev/mapper/mint--vg-root /               ext4    noatime,errors=remount-ro 0       1
thank you
i will try that

hcentaur13
Level 4
Level 4
Posts: 394
Joined: Sat May 18, 2013 5:13 pm

Re: Optimize SSD's for Longer Lifespan

Post by hcentaur13 » Sat Mar 16, 2019 10:43 am

Increase your RAM size to 8 or 16 GB and you'll need swap only as cheap extend of real RAM for the rare case that existent RAM needs to be extend a bit.

Current SSDs have in default less live time than the best existent server drives. They run with guarantee more than 5 years 24h 7d/week. Ony 3 or more years old SSD may have noteable livetime when they get constantly switching power on/off. Never by writing to it.

Post Reply

Return to “Tutorials”