disk – openSUSE Lizards https://lizards.opensuse.org Blogs and Ramblings of the openSUSE Members Fri, 06 Mar 2020 11:29:40 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.5 SSD configuration for openSUSE https://lizards.opensuse.org/2015/02/06/ssd-configuration-for-opensuse/ https://lizards.opensuse.org/2015/02/06/ssd-configuration-for-opensuse/#comments Fri, 06 Feb 2015 19:04:12 +0000 http://lizards.opensuse.org/?p=11246 As you already know, there are mechanic disks and also SSD. There is the rumor that SSDs last for 5 years or up to 5 years. Read the openSUSE wiki page for more information about openSUSE and SSD.

Here I’ll describe what I did to my SSD.

RULE 1: Partitioning

The first step is creating the right partitions. First of all, create the root partition (about 15-20GB is enough). Then create the home partition (/home). Finally leave about 7% of the disk unallocated. This will help your disk during write process. The right filesystem is ext4.

If you have new computer, then you should have a partition /boot/efi. You don’t have to do any of the following configuration for that partition.

BE CAREFUL: Don’t create a swap partition. If you already have enough memory (4GB), you don’t need it. Swap memory is “destroying” your SSD. Finally, be careful of the file system, since openSUSE 13.2 uses BTRFS as default filesystem. Snapper will create snapshots, something that you don’t need.

RULE 2: fstab

Open fstab and make some changes there:

sudo nano /etc/fstab

Delete relatime (if any) and add noatime

Your fstab will look like

/dev/sdaX     /          ext4 noatime,acl,user_xattr 0 1
/dev/sdaY    /home ext4 noatime,acl,user_xattr 0 2

 

Now, move everything to RAM. You can do that by adding the following lines to fstab.

tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0

To restore the folder structure within /var/log at each reboot, you add some lines to /etc/rc.local.

sudo nano /etc/rc.d/boot.local

Add the following lines, just above the line “exit 0” in that file (use copy/paste to avoid errors):

#
# Modification for SSD
for dir in apparmor apt cups dist-upgrade fsck gdm installer samba unattended-upgrades ;
do
if [ ! -e /var/log/$dir ] ; then
mkdir /var/log/$dir
fi
done

RULE 3: Browsers

You can limit the write actions of Firefox as follows.
1. Set the cache to 0:
Firefox menu button (with the three dashes on it) – Preferences – Advanced Tab Network section Cached Web Content: tick Override automatic cache management and set the cache to 0 MB.

2. If you have installed Oracle Java, limit the write actions of the Java plugin:
launch the Java Control Panel – Tab General: Temporary Internet Files – Settings…  Remove the tick for: Keep temporary files on my computer.

The write actions of Google Chrome and Chromium can be limited as follows.
1. Launch Chrome / Chromium.
2. Now press the F12 key, in order to open the developers’ console. In that window you click on the gear wheel in the bottom right, in order to open the settings. See the screenshot below (click on it to enlarge it):

In the settings window you tick: Disable cache.

Press F12 again to close the developers’ console.

RULE 4: SWAP

As described at RULE 1, you shouldn’t add a swap partition. If you did (or did by automatic installation), you should disable it.

First of all, check the status:

cat /proc/sys/vm/swappiness

If the result is 60, then you should reduce to 1.

sudo nano /etc/sysctl.conf

and at the end of the file, add the following lines

# Sharply reduce swap inclination
vm.swappiness=1

RULE 5: HIBERNATION

Hibernation causes a huge amount of write actions, which is very bad for an SSD. Make sure it’s disabled, by removing the package pm-utils.

sudo zypper rm pm-utils

RULE 6: TRIM

The TRIM technology is like defragment on windows. It makes the disk faster. You can use 3 ways of running it. Usually, the command is fstrim -v / but when run it, I failed. So that’s why I added sudo, just to be sure.

1. As alias at .bashrc and run when you want.

Create an alias for both ext4 mounted partitions.

$ sudo /usr/sbin/fstrim -v /
$ sudo /usr/sbin/fstrim -v /home

2. Add the commands to /etc/rc.d/boot.local and run on each boot.

Just open the /etc/rc.d/boot.local

sudo nano /etc/rc.d/boot.local

and add the following line

sudo /usr/sbin/fstrim -v / && sudo /usr/sbin/fstrim -v /home

3. If you run a server or something (your system is always on), then you have to use cron.

sudo nano /etc/cron.daily/trim

Then add the following lines

#!/bin/sh
sudo /usr/sbin/fstrim -v / && sudo /usr/sbin/fstrim -v /home

and finally make it executable

sudo chmod +x /etc/cron.daily/trim

openSUSE will now perform the daily cron job automatically, at 06:25, or (when the computer isn’t on at that time), automatically at a later time on the same day.

RULE 7: I/O SCEDULER TO DEADLINE

By default, openSUSE still uses the “old” I/O scheduler CFQ, which is only fine for conventional hard disks but not for SSD’s, which are being slowed down. So it’s wise when you have an SSD in your machine, to change the scheduler to Deadline, which is good for both SSD’s and conventional platter hard disks.

You can realize this by changing the boot parameters of Grub. You can do that as follows.

Check your current scheduler as follows:

cat /sys/block/sda/queue/scheduler

(if your drive isn’t sda, change the line accordingly)

The output will probably be:

noop deadline [cfq]

Which means: cfq is active, but noop and deadline are also supported.

Now type:

sudo nano /etc/default/grub

Find the line: GRUB_CMDLINE_LINUX_DEFAULT=

This line may look like this (example):
GRUB_CMDLINE_LINUX_DEFAULT=” resume=/dev/sda1 splash=silent quiet showopts”

And add the option elevator=deadline.

Example:
GRUB_CMDLINE_LINUX_DEFAULT=” resume=/dev/sda1 splash=silent quiet showopts elevator=deadline”

Save the modified file and close it.

Now update Grub for this change. In the terminal:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

]]>
https://lizards.opensuse.org/2015/02/06/ssd-configuration-for-opensuse/feed/ 4