Sunday, June 9, 2013

Adventures in Arch (Part II): Fine Tuning

Arch Linux
Last updated: 2013-11-04

In this part I will show the fine tuning I made in the system.
I will keep updating this post in the next weeks, in case I have other tips.


fstab

Since I have the system installed in a SSD drive, I changed the mount flags in fstab to trim the drive:
$ sudo nano /etc/fstab
UUID=aee33023-2254-42fc-94ac-612314eeb332   /   ext4   noatime,discard,data=ordered,errors=remount-ro   0 1
UUID=114aaab1-1cb8-4853-bacc-819237d2d063   /boot   ext4   noatime,discard,data=ordered,errors=remount-ro   0 2
I also mounted /tmp in memory:
tmpfs   /tmp   tmpfs   nodev,nosuid,noatime,mode=1777   0 0

I/O Scheduler

Check your scheduler:
$ sudo cat /sys/block/sda/queue/scheduler
noop deadline [cfq] 

Get the SSD disk ID:
$ sudo ls /dev/disk/by-id/
ata-Corsair_Force_3_SSD_12066504000008910711

Change the scheduler to noop at boot time:
$ sudo nano /etc/rc.local
#!/bin/sh
declare -ar SSDS=(
   'ata-Corsair_Force_3_SSD_12066504000008910711'
)
for SSD in "${SSDS[@]}" ; do
   BY_ID=/dev/disk/by-id/$SSD
   if [[ -e $BY_ID ]] ; then
      DEV_NAME=`ls -l $BY_ID | awk '{ print $NF }' | sed -e 's/[/\.]//g'`
      SCHED=/sys/block/$DEV_NAME/queue/scheduler
      if [[ -w $SCHED ]] ; then
         echo noop > $SCHED
      fi
   fi
done
Create a rc-local.service to start with system.d (see this tip):
$ sudo nano /etc/systemd/system/rc-local.service
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99 
[Install]
WantedBy=multi-user.target
Enable the service in systemd:
$ sudo systemctl enable rc-local.service
$ sudo systemctl start rc-local.service

Swap

I didn't create a swap partition.
$ sudo nano /etc/sysctl.conf
vm.swappiness = 0

Preloading

More on this topic here.
$ sudo pacman -S preload
$ sudo systemctl enable preload

Zram

More on this topic here.

Download from AUR.
$ cd builds
$ tar -xzf zramswap.tar.gz
$ cd zramswap
$ makepkg -s
$ sudo pacman -U zramswap-1.1-1-any.pkg.tar.xz
$ sudo systemctl enable zramswap.service

Chrome cache

Having installed Chrome, I adapted this script to move the cache into memory.
$ mkdir -p bin/google-chrome_cache
$ nano bin/google-chrome_cache/tmp_cache.sh
#!/bin/bash
if test -d /tmp/google-chrome; then
  exit 0
else
  rm -r ~/.cache/google-chrome
  mkdir /tmp/google-chrome
  ln -s /tmp/google-chrome ~/.cache/google-chrome
fi
$ chmod +x bin/google-chrome_cache/tmp_cache.sh
$ nano .config/autostart/google-chrome_cache.desktop
[Desktop Entry]
Type=Application
Exec=/home/youruser/bin/google-chrome_cache/tmp_cache.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=google-chrome_cache.desktop
Name=Chrome Cache
Comment[en_US]=Move Chrome cache to /tmp
Comment=Move Chrome cache to /tmp
Font Rendering

$ sudo nano /etc/pacman.conf
[infinality-bundle]
SigLevel = Never
Server = http://bohoomil.cu.cc/infinality-bundle/$arch
[infinality-bundle-multilib]
SigLevel = Never
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch
$ sudo pacman-key -r 962DDE58
$ sudo pacman-key --lsign-key 962DDE58
$ sudo pacman -Syu
$ yaourt -S freetype2-infinality fontconfig-infinality lib32-freetype2-infinality libreoffice-uglyfix-freetype2-infinality
$ sudo nano /etc/fonts/local.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">

  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
  <edit mode="assign" name="lcdfilter">
    <const>lcddefault</const>
  </edit>

 </match>
</fontconfig>
Check this for more information.