Do you need to optimize your SSD?

MagicMint
  9 years ago
  10

The answer is no if you’re an optimist smiley, and yes if you’re a pessimist sad yet a benchmark believer. Fact is, a Solid State Drive is internally totally different from magnetic hard drives: as the well-known USB pen drives or SD cards, with which it shares the same flash technology, it does benefit from the fewest write cycles as possible. This will surely extend its life span since any write access will inevitably shorten it, due to technology limitations — and if your SSD happens to be soldered to the motherboard, as it is the case of the smaller boot-up disk in my Asus Zenbook, this kind of optimization matters to you all the more. You can then just as well squeeze out a little bit of additional performance from your SSD if you like.

Preliminary steps

With the help of the GNOME disk utility, you can easily find out which one of your disks is the SSD you need to prevent from damage (Mint Menu› Accessories› Disks):

…$ gnome-disks

After having made a security copy of your file system table, look into its contents in order to find out how it designates the single partitions. It can do it either by labels or by so-called UUIDs; both of them can easily be listed for your system with a third command:

…$ sudo cp -i /etc/fstab /etc/fstab.bak
…$ cat /etc/fstab
…$ sudo blkid

Finally, you can edit the file system table by:

…$ sudo gedit /etc/fstab

Less unnecessary writes

For each non-swap partition on the SSD, you should make the defaults,… options contain the words “noatime” and “discard”. As an example, take the root partition and assume it to be designed by its label (as in LM14 Nadia, e.g.):

# FileSys  MountPt Type Options                  Dump Pass
LABEL=ROOT /       ext4 defaults,noatime,discard 0    1

If the trimming is done this way, it is performed at each delete operation. In LM 17.1 Rebecca, there is now a background trimming job scheduled on a weekly basis at /etc/cron.weekly/fstrim which is aimed at every SSD, but it works by default only if the disk is made by Intel or Samsung.

If your system is stable in other respects, i.e. you don’t have to look into the system logs immediately after booting up, you can redirect the latter into the RAM:

# FileSys MountPt  Type  Options                             Dump Pass
tmpfs     /tmp     tmpfs defaults,noatime,mode=1777,size=15% 0    0
tmpfs     /var/log tmpfs defaults,size=5%                    0    0

If you have the possibility to transfer the /var directory from the SSD to a normal hard disk, you should do it, because it is the only physical system directory which is subject to heavy write usage (think of package upgrades).

As far as the swap partition is concerned, you should weigh up the following points:

  • If you have enough RAM for your working load, then you won’t need the swap partition for anything else than for hibernation, and that will hardly affect the SSD more than its normal day-to-day usage;
     
  • If you don’t have enough RAM, then the frequent swapping of memory contents onto the SSD will wear it out too soon, so consider either to upgrade your RAM or place the swap partition on another disk.

Faster writes

The command blkid — or even better the look into Disks — at the beginning has also revealed the device name of the SSD which is something like sda, sdb,, etc. If this name doesn’t change upon restarts (i.e. you or the computer don’t re-arrange the disks), you could go for optimization of your SSD. With the following commands you can check if you need to at all (replace sdX by the device name of your SSD):

…$ cat /sys/block/sdX/queue/rotational
…$ cat /sys/block/sdX/queue/scheduler

If the first gives you a 0 and the second a list in which the active scheduler (the one surrounded by square brackets) is either “deadline” or “noop”, then the kernel itself takes care of the peculiarities of the SSD already. If not, then you should try one of the following tweaks:

Note that such a write optimization doesn’t matter in the dual disk setup of some Ultrabooks like mine.

Avoid “the fuller, the slower”

We have done so already wink by enabling the “discard” (the trash) option in the file system table further above, so all you have to do is to restart the computer…

Comments
donalduck 10 years ago

first tuto on SSD, more to come I hope, because there is a lot more settings indeed.


zantaz 10 years ago

too techinical ... too nasty ...


MagicMint 10 years ago

@xen2050: This tutorial is just about optimization of an already existing (and well working :-) installation). You should _always_ think of your swap partition _before_ installing a Linux system.

Though you can modify it from a live CD by using GParted (or any other partitioning software) with care and manually editing, i.e. removing the swap line from fstab, it’s a lot easier and much safer to configure it when you install your system in the first place.


xen2050 10 years ago

Good! Would like to see more info on disabling swap completely, or moving it to another partition, definitely important to SSD life, but probably a little out of scope here, but at least a good link could be added?


ericvictor66 10 years ago

thanks! Very usefull


yurayko 10 years ago

Somethings (good) about this we can see here: http://forums.linuxmint.com/viewtopic.php?f=191&t=135012


Hammer459 10 years ago

Good tutorial with reason, problem description and step-by-step description of what to do