fb autocomment to a specific post | date code in php | distro debian server | how to overlay two photos gimp
 


 

Tweak SSD Drive in Ubuntu 16.04 Workstation


Tweak SSD Drive in Ubuntu 16.04 Workstation

Image source: French Alpha Jet



An SSD (Solid State Drive) will really speed up your computer. It will significantly reduce the boot time and increase the response of most software applications.

Every write action to a SSD will result in the undesirable phenomenon known as write amplification. This may shorten the life of the SSD.

Ubuntu 16.04 seems to be ready for SSD drives. Here are some steps you should take to extend the life of your SSD drive. The keypoint is to reduce write actions.

  1. add noatime to fstab
  2. run fstrim periodically (default on Ubuntu)
  3. reduce the use of swap (optionally in systems with enough RAM)
  4. avoid hibernation ("disabled" on Ubuntu)

1. Add noatime to fstab

Every time you access a file, Linux makes a write action with access date and time. This is known as "access time stamp". With noatime option you disable the "access time stamp".

You must add the option noatime in fstab. fstab (File System Table) describes the disk partitions and their parameters. This file is read at boot time, so Linux mounts partitions automatically.

In my workstation I have an INTEL SSD 240GB. The full model name is "SSD INTEL 540S SERIES SSDSC2KW240H6X1 240GB 2.5'' SATA3 TLC SINGLE PACK (S.M.A.R.T. enabled)". Here are the partitions I have created:

(click the thumb for full image)

First things first. Create a backup of your fstab

sudo cp /etc/fstab /etc/fstab.bak

Then, edit fstab using your favorite text editor (nano in my case)

sudo nano /etc/fstab

Add noatime to partitions definition. I added noatime option to root (/) and data partition:

# /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>
# / was on /dev/sda2 during installation
UUID=6e302c82-a375-4b8d-ad18-c25abf8950ad /               ext4    noatime,errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
#UUID=d8c5f04a-1da8-4120-8db8-be63f55fdcf3 /boot           ext4    defaults        0       2
# /data was on /dev/sda4 during installation
UUID=d3ea7a13-4bba-4256-9561-bc06cae90113 /data           ext4    defaults,noatime        0       2
# swap was on /dev/sda3 during installation
UUID=acf361da-b633-48b7-8ef5-8b482f7b3983 none            swap    sw              0       0
UUID=d8c5f04a-1da8-4120-8db8-be63f55fdcf3       /boot   ext4    defaults        0       2

Reboot your system. Use the top desktop menu or command line:

sudo systemctl reboot

2. Run fstrim periodically

According to Linux man pages:

fstrim is used on a mounted filesystem to discard (or "trim") blocks which are not in use by the filesystem. This is useful for solid-state drives (SSDs) and thinly-provisioned storage.

By default, fstrim will discard all unused blocks in the filesystem. Options may be used to modify this behavior based on range or size, as explained below.

Before use trim, ensure your SSD supports it. Run:

lsblk -D

here is the result in my case

NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0      512B       2G         0
├─sda1        0      512B       2G         0
├─sda2        0      512B       2G         0
├─sda3        0      512B       2G         0
└─sda4        0      512B       2G         0
sr0           0        0B       0B         0

Non-zero values for DISC-GRAN and DISC-MAX indicate TRIM support.

Ubuntu has already created a weekly cron job /etc/cron.weekly/fstrim. If not, create it by yourself:

sudo nano /etc/cron.weekly/fstrim

add

#!/bin/sh
# trim all mounted file systems which support it
/sbin/fstrim --all || true

3. Reduce the use of swap

Modern systems have enough RAM (4GB or more), so they use swap memory very rarely. In this case, you have nothing to do. Otherwise:

Using your favorite text editor (nano in my case)

sudo nano /etc/sysctl.d/ssd.conf

add

# Reduce swap using
vm.swappiness=1

Reboot your system. Use the top desktop menu or command line:

sudo systemctl reboot

4. Avoid hibernation

In Ubuntu, hibernation does not exist in shutdown options. However, avoid hibernation as it causes a large number of write actions on the disc. So, in the long term, it may affect your SSD speed.

Related Posts

You may also be interested in

Εγγραφή!
Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

How to Use APC UPS with Two or More Computers - Master Slave Setup Manage Your Passwords With KeePass in Linux And Android