configuration – 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
YaST module the C++ way https://lizards.opensuse.org/2008/07/15/yast-module-the-c-way/ https://lizards.opensuse.org/2008/07/15/yast-module-the-c-way/#comments Tue, 15 Jul 2008 16:24:44 +0000 http://lizards.opensuse.org/?p=99 From May 30th to July 4th we had a YaST workshop in Nuremberg. The workshop was basically a hackshop as we wanted to work on cool and new things for YaST during this week.

There is one big change in YaST in openSUSE 11.0 – yea, we found out that there are even more colors than gray, ok – but there is one that is not really visible to the end-user. Stefan Hundhammer, maintainer our YaST UI, completely separated the UI from the rest of the YaST infrastructure. This now makes it possible to use the UI directly, from anywhere, independent from our YaST-own-language YCP. So with a team of four hackers we wanted to prove that we can write a YaST module in plain C++ using the new modularized UI directly. And here is the outcome:

We went for rewriting the registration module (well, we chose it because I know it well, as I am the maintainer, and it will change anyhow for the next release). This module is not that integrated in the overall YCP world, so it should be feasible. First we had to find an alternative way to access system configuration files, as this is done by so-called SCR agents in YCP. To make life easier (and future development faster) we had to look for a replacement of our YCP Wizard Seqencer. And of course we redesigned all dialogs to make them more intuitive.

We solved all the issues and now have

  • a wrapper class for accessing different configuration files (currently only ini files)
  • an automatic wizard sequencer equivalent (using the advantages of an object oriented language, btw YCP is not)
  • three clear and intuitive dialogs, every user should understand

And as everybody wants to see screenshots, here they are:

Configure Update Source Send Hardware Information Register for Installation Support

The code is just a proof of concept and not yet reusable for new YaST modules but everything we wanted to show works great. We will continue to work on such kind of modules and in that process move the generic parts out into single libraries so that they can be reused and even may be exposed to scripting languages.

Writing YaST module this way has lots of advantages

  • YaST modules evolved into the object oriented world and can make use of it (the automatic sequencer is the first benefit)
  • the code is reusable
  • a huge bunch of documentation and lots of tools exist for C++
  • its a compiled language and has a better performance than an interpreted one
  • we can bind automatically to the most important scripting languages and give them access to the modules logic

If you are interested in the source code, have a look at my svn repo and if you want to help join the team and contact us on our mailinglist.

]]>
https://lizards.opensuse.org/2008/07/15/yast-module-the-c-way/feed/ 4