SSD

From ZENotes
Revision as of 07:10, 7 February 2017 by Admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

From http://www.makeuseof.com/tag/optimize-linux-ssds/

Contents

Original piece

Every time you boot your Linux system, it must mount the various drives in your computer in order to use them. There are various mount options you can use, depending on your hardware and your needs, and some are appropriate to use with SSDs.


To make these changes, open up your terminal and run the command sudo nano /etc/fstab. Next, find the partition(s) in your SSD(s) that are listed in this file. Partitions here are normally listed by UUID, which is more precise than the /dev/sdXY identification system. If you have multiple partitions, you can use the command blkid /dev/sdXY to find the UUID, replacing X with a-z and Y with 1-9.


Then, add the following mount options: discard and noatime. Discard allows the SSD’s TRIM function to be used – this improves performance and longevity. The other option, noatime, tells the filesystem to not keep track of last accessed times – just last modified times. This can reduce wear and tear on your SSD, because there are many files that you access while you use your computer but there are far fewer files that you’ll end up modifying. The file should look similar to the screenshot above.


If you find that some programs are misbehaving with the noatime option (as last accessed times will be before last modified times, which is normally impossible), you can replace noatime with relatime. This updates the last accessed time with the same value as the last modified time, all in the same write operation.


When using an SSD, it’s also a very good idea to not have a SWAP partition on it (unless you have a serious reason to do so).


The constant reads and writes SWAP partitions do add significant wear-and-tear to the SSD. If you really would like to have a SWAP partition, it’d be better to place it on a secondary, non-SSD hard drive if at all possible. I know it’s tempting to put a SWAP partition on an SSD – it would be the best-performing SWAP partition you’ll ever have – but this speed comes at a major cost.


A lot of people suggest that you can still add a SWAP partition but disable hibernation, since that causes extreme amounts of reads and writes. But since it’s rare that you’ll use a SWAP partition, as you probably have more than enough RAM, it’ll just take up space and potentially cause wear-and-tear. Also, not including a SWAP partition to begin with is an easy way to disable hibernation Conclusion


These tips should get you well on your way to a much more optimized SSD experience on Linux. And your SSD will thank you by lasting a few years longer than it would without these optimizations. If you feel lucky, you can research even more SSD-related optimizations that may not be for the faint of heart. It’s up to you, but these tips do the most amount of good for your SSD. Most other tweaks are only nitpicks that provide a minimal difference.


Comments

1

You don't have to eliminate a swap file to eliminate its use except near catastrophically, e.g. almost never. Just reduce Linux default "swappiness" from 60 to 6. What that means is that swap will only start being utilized when 40% of RAM has been used, by default, which made sense back in the days of 64MB of RAM, circa 1999, but not now. By reducing it to 6, fully 94% of RAM must be in use before the swap file kicks in. Here is how to do it:


Here's how you adjust swappiness and activate write behind caching in Linux: TO FIND SWAPPINESS:

cat /proc/sys/vm/swappiness
TO SET SWAPPINESS (if >= 2 GB RAM):


sudo leafpad /etc/sysctl.conf


Add line:

cvm.swappiness = 6


TO SET WRITE CACHING:

Open Disks. (Package name: gnome-disk-utility. Command: gnome-disks.)

(sudo apt-get install gnome-disk-utility)

Click 'Drive Settings' in menu.

Set 'Write Cache' to On.

Ouch

There are a number of bad ideas in this article, based on common myths and misunderstandings.


First, never use the "discard" option. Online TRIM is a bad idea. This is not because the Linux kernel's implementation is poor - it is that the specifications of the TRIM disk command are idiotic. I don't want to go into details here - look them up if you want. But the result is that "discard" makes metadata operations far slower. It is much better to do an offline "fstrim" on occasion (I believe many distros will do that by default) - or if you have a reasonably modern SSD that is fairly good quality, just ignore TRIM altogether and let the SSD's garbage collection and overprovisioning handle everything.


You will /never/ wear out your SSD - modern devices can be written to continuously for years without wearing out. So put /var, swap, etc., on the SSD without worrying.


The most efficient choice for /tmp is tmpfs. If you want to store a lot of files in /tmp, keep it tmpfs and make sure you have plenty of swap. It is faster (and less wear on your SSD) to have files in tmpfs spilled out into swap than putting them on a normal filesystem.


ext4 is a good filesystem, but not because of "discard". btrfs is also a solid choice these days for people looking for more features.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox