Friday 30 September 2011

Undocumented dependencies

Recently I decided to clean up my laptop so I reviewed my installed packages and removed quite a nice amount of those that I thougt I do not need any more. After rebooting my system I realised that some programs stopped working. There are some dependencies that are marked as optional or even not marked at all but still if you do not install them your application will not work properly (or at all). I have to admit these problems were very rare and after some time I could resolve the problem. In this post I am collecting such not very well documented dependencies. If I find more I will update the entries below.

Blueman needs gconf, gnome-icon-theme and libnotify to work properly! Unless you will not have an applet in your systray and/or you cannot connect to any device via bluetooth.

Wicd client needs xfce4-notifyd, other notification daemons (i.e Gnome's notification-daemon) do not work with it.

Friday 23 September 2011

Tiling window managers

My first try with tiling window managers was ion3. I liked it and used it for months. I loved its keystroke-driven minimalistic approach. Although the Lua config was too high for me, I could not set things up correctly. It did not support fancy titlebars nor a systray, it simply worked. I saw its limitations and I was a bit sad that the developers did not support the software any more, so I went back to Gnome. Nowadays as I started using Arch Linux I needed something powerful and tiling WMs came to my mind again. So I made some research and tried some of them. Here is my short review of them.
 
 The WM I need is a tiling window manager with:
- Configurable keyboard shortcuts
- Tag bar (to see which tag I actually use), urgent tag is preferred
- Systray
- Statusbar (with configurable contents of computer state like clock, cpu, battery, etc.)
- Easy-to-use config file (I do not want to learn programming languages to set it up!)
- Dual-head support
- Rules to place different applications where (screen and workspace) I want and how (floating or tiling) I want.

Here are the ones I tried:

Awesome
Awesome is simply awesome. It has almost everything I need: It handles dual screen (although it was sort of a pain to set it up and still I have problems with it), there is a built-in taskbar and systray: good point! The lua configuration language is too diificult for me. I just do not see logics and simplicity here, there are redundant solutions for things and above all the config syntax changes from one version of Awesome to another. Maybe I will come back later again.

Subtle
Subtle is an easy-to-set-up tiling WM but I could not get dual head working on it properly. Possibly it is my fault, I did not spend too much time with it.

Xmonad
At first sight I liked it but it has a frightening config file written in Haskell and you have to load third-party plugins to access basic features (like statusbar, systray, etc.).

i3
i3 is very close to my expectations. I only have one complaint against it: it does not support a configurable statusbar (although it has a built-in one, it contains too much and useless information but others are missing) nor a native systray. Somehow I could not get third-party statusbars and systrays working in my dual head setup. They always overlapped, windows were ignoring them, etc. I might have done dirty hacks to get it work but I gave it up. Anyway, nice project.

Scrotwm
Simple, very easy to configure but lacks major features like tags and rules.

Wmfs
After quite a lot of experimenting with so much WMs out there I found Wmfs. It has a very straightforward configuration file and you do not have to include plugins or third-party software. Multi-head setup works very well and can be set up as easily as everything else. The "bar" contains a taglist, a layout chooser, the title of the actual window, a message where you can place any text with some formatting (i.e. a static text or a status message updated regularly by a shell script) and a systray. Everything can be driven by keystrokes and rules can be assigned to many different window properties. This is the first tiling WM that I could set up properly with one simple(!) config file and it just works fine with all the main features I expected. I have some minor issues though:
- If I run xrandr, the system crashes. This means that hot-changing of single / dual monitors does not work. For example if I plug in an external display to my laptop and run xrandr to set my dual screen up, all my running applications are killed and the WM hangs. Maybe there will be a solution for this soon, but by that time I have to be careful with this.

- The titlebar shows only the title of the actual window. Right clicking shows the other clients of the actual tag but it is not convenient to use. A bar with all the windows of the actual tag would be nice with color mark for the actual client (just like in Awesome). This is not a major issue but it would be very informative to have such a feature.
- Using regexps or wildcards in rule definitions would be very handy. This is a nice-to-have feature, I can live without it.

My Wmfs dual-head GUI looks like this:



You can find my actual wmfsrc config file, wmfs-status message generator script (for indicating the date, time, battery and processor state invoked from .xinitrc regularly) and my .xinitrc file in the right panel under "My actual config files".

Wednesday 21 September 2011

Powerful networking with Wicd

Wicd is a very clever network manager. It is independent of any desktop environments meaning that it is compatible with any window managers. It has a daemon running in the background and a client with a ststus icon in the systray and a cool GUI to manipulate your network connections. Wicd handles both wired and wireless connections. You can set it up to automatically connect to the wired network when you plug in your ethernet cable and in other circumstances connect to your preferred wifi access points.

Installation is easy, just follow the Wicd Arch Wiki. I put the wicd daemon in my /etc/rc.conf (after dbus) and disabled the original networking daemon:
DAEMONS=(...dbus ... !network ... wicd ...)
I edited my .xinitrc to run the client when X starts:

...
wicd-client &
...
exec ck-launch-session wmfs

(See my actual rc.conf and .xinitrc files on the right panel of this blog.)

Above the basic networking services Wicd gives you scripting possibilities to execute programs on different networking events and different networking environments. This feature is very useful for laptops that are brought from one network to another (home / office / net café, etc.) and the behavior of the machine can be altered according to the network it is connected to. Just some ideas:
- You can automatically mount nfs and/or samba shares when you connect to your office network.
- You can start or stop daemons according to your network connection (i.e. if you use network printers you can set up your cupsd service to start only at places where you use printers).
- You can switch off your wi-fi antenna after disconnecting from a wireless network to gain battery life when your laptop is running on battery power.

Mainly I use my laptop in my office and at home. In the office I have both wired and wireless networks (at my desk I usually plug in the network cable but when I am at a meeting in another room I use wi-fi). I need the same settings for both cases. At home I use wireless internet, I do not have a printer nor do I use nfs file shares. I want to access samba shares anywhere.

You can find the preconnect, postconnect, predisconnect, postdisconnect directories under /etc/wicd/scripts/. Bash scripts placed in these directories are executed each time the appropriate network event (the nemes of the directories are self-explanatories) occurs. I use two of them but their usage depends only on your creativity.

I created a share_mount.sh script that runs after wicd connects to a network and a share_umount.sh that runs before disconnecting. If the network is wired or the wireless ESSID belongs to my office's wifi router then I start the rpcbind and nfs-common daemons to use nfs, the cupsd daemon for printing and I mount my office nfs shares (defined previously in fstab with noauto option). In all networks I start samba and smbnetfs to automatically mount samba shares after network connection. Logs go to the /etc/wicd/<script_name>.log file. I used wicd's sample scripts to build up my own ones:

Postconnect script ( /etc/wicd/scripts/postconnect/share_mount.sh ):

#!/bin/bash

script="$(basename "$0")"
script_name="${script/.sh/}"

echo "Running ${script}" >"/var/log/wicd/${script_name}.log"
exec 2>>"/var/log/wicd/${script_name}.log"
exec 1>&2

connection_type="$1"
echo "Connection type: ${connection_type}"

if [ "${connection_type}" == "wired" ]; then
profile="$3"
echo "Profile: ${profile}"
elif [ "${connection_type}" == "wireless" ]; then
essid="$2"
bssid="$3"
echo "ESSID: ${essid}"
echo "BSSID: ${bssid}"
else
echo "Unknown connection type: ${connection_type}" >&2
exit
fi

case $2 in "wired" | "myoffice_essid")
# I am at office:
rc.d start rpcbind nfs-common cupsd;
mount -a -t nfs;;
esac
# I am anywhere:
rc.d start samba smbnetfs


Predisconnect script ( /etc/wicd/scripts/predisconnect/share_umount.sh ):

Before disconnecting a network this script handles the file unmounting and daemon stopping process in the opposite way I used in my connect script.

#!/bin/bash

script="$(basename "$0")"
script_name="${script/.sh/}"

echo "Running ${script}" >"/var/log/wicd/${script_name}.log"
exec 2>>"/var/log/wicd/${script_name}.log"
exec 1>&2

echo umounting nfs and smb filesystems
#umount /media/Erba_nfs
umount -a -t nfs
rc.d stop cupsd smbnetfs samba nfs-common rpcbind


Wicd's actual (1.7.0) version is not able to handle ad-hoc networking. Scripts can help you again, see the workaround here.

Tuesday 20 September 2011

Kernel panic after upgrade

Some weeks ago after pacman -Syu my system did not boot at all.

It said something like "modprobe: FATAL: Could not load /lib/modules/.../modules.dep: No such file or directory."

After a hard work of recovery described in the Kernel Panics Arch Wiki and rebooting my system all went fine but upgrading the system again caused the same error.

After some hours of panicking I found the solution here:
https://bbs.archlinux.org/viewtopic.php?id=96794

My /boot partition was not mounted when I upgraded my kernel, so the upgrade process could not copy the appropriate files to this area. Instead it created a separate /boot directory under my mounted root filesystem. The system wanted to boot from the /boot partition but the upgraded kernel was not there.

I propose two solutions (I chose No. 2):

1. If you keep your /boot partition unmounted and you see thet pacman wants to upgrade your kernel then stop the upgrade process, mount your /boot partition and start the upgrade in this state.

2. If you do not want to take care of manual mounting then add a line to your /etc/fstab to mount your /boot partition automatically.

And another suggestion:
Keep an Arch Linux installation medium on a usb stick, it can be very handy to have one at panic time... I wish that you do not need to use it ever though!

Thursday 15 September 2011

A simple bluetooth setup

I set up bluetooth on my Thinkpad Edge 11 this way:

# pacman -S bluez
# pacman -S blueman

I edited my .xinitrc to start blueman-applet when X starts:

...
blueman-applet &
...
exec ck-launch-session wmfs

The tricky part is to be sure that you run your window manager (my one is wmfs) with exec ck-launch-session. If you simply use exec <yourwindowmanager> then the blueman-applet will not work! It will give you ugly exception error messages like this:

Exception AttributeError
dbus.exceptions.DBusException

I suffered some hours to get this done but now everything works fine.

I start bluetooth daemon at boot time by inserting (...dbus...@bluetooth...) in the DAEMONS array of my /etc/rc.conf.

and the blueman-applet icon appears in my systray immediately after starting X, I only need to click on it and manage my bluetooth connection in a nicely built GUI. The bluetooth state (on/off) will be preserved for the next boot, so I do not need to worry about unintentional battery drainage because bluetooth switched itself on at boot time (unless I left my antenna switched on when I stopped my machine).

WARNING: blueman needs some packages that are marked as only optional to work properly. See my post about undocumented dependencies.

Wednesday 14 September 2011

Networking mystery with Realtek r8169

eth0 stopped working. Maybe due to the 3.0 kernel upgrade?
dhcpcd showed "Link is not ready" and "no carrier" and I could not get an IP.
I tried dhclient instead of dhcpcd, no results, although dhclient seems to be a nicer solution in general (more informative log output and faster connection in my opinion).

My ethernet driver according to lspci -v is:

09:00.0 Ethernet controller:
Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)

Subsystem: Lenovo Device 21c5
Flags: bus master, fast devsel, latency 0, IRQ 42
I/O ports at 2000 [size=256] Memory at f0804000 (64-bit, prefetchable) [size=4K] Memory at f0800000 (64-bit, prefetchable) [size=16K] [virtual] Expansion ROM at f0820000 [disabled] [size=128K] Capabilities: [40] Power Management version 3 Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+ Capabilities: [70] Express Endpoint, MSI 01 Capabilities: [ac] MSI-X: Enable- Count=4 Masked- Capabilities: [cc] Vital Product Data Capabilities: [100] Advanced Error Reporting Capabilities: [140] Virtual Channel Capabilities: [160] Device Serial Number 4e-00-00-00-68-4c-e0-00
Kernel driver in use: r8169
Kernel modules: r8169

Google says that the r8169 driver is buggy, if any problem occurs installing a newer driver can help. Ok. How?

* If you have the same issue, please go to the end of this post for a possible solution, you might not need to do all these steps I made.

AUR's r8169 package did not work for me, the download link had an authentication problem, the driver could not be downloaded.

OK. Let's find another source, realtek's homepage:

http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=5&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false#RTL8111B/RTL8168B/RTL8111/RTL8168%3Cbr%3ERTL8111C/RTL8111CP/RTL8111D%28L%29%3Cbr%3ERTL8168C/RTL8111DP/RTL8111E%3Cbr%3ERTL8168E/RTL8111F

Actually this package should install the r8168 driver and remove the native r8169 one.
After clicking on several dead links on Realtek's page one moment I could finally download the "LINUX driver for kernel 2.6.x and 2.4.x (Support x86 and x64)" (8.025.00 ) driver package.
I unpacked the tarball and went on the way that the README said but again I faced a problem: the r8168 module could not be loaded (modprobe r8168 said: "FATAL: Module r8168 not found."). At the same time r8169 could not be loaded either (the installation moved it to somewhere else), so now i had no ethernet driver at all. Sad thing, now what?

Googling again I found the solution after a day of madness:
Download the above mentioned Realtek driver package, untar it, step into the install directory, run the autorun.sh according to the README. After do this as root (still in the installation directory):

depmod -a
insmod ./src/r8168.ko
cp ./src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
modprobe r8168

Now the last two lines of lspci -v have to say something like this:
Kernel driver in use: r8168
Kernel modules: r8168

(instead of r8169).

Now edit your /etc/rc.conf and put r8168 into the MODULES section. If r8169 was there then delete it or restrict it with (... r8168 !r8169 ...)

Huh, that was a hard day!

* And now I see that AUR has a r8168 package. Probably installing this could have solved my problem in one step but it is too late, I have done it in a different - apparently much more difficult - way. Please try this AUR package first if you have a similar problem. You still might need to change your daemons array in your rc.conf to use the newly installed driver instead of the old one.

Tuesday 6 September 2011

Partitioning, installation, first settings

OK, let's start blogging! I conclude how I installed Arch Linux, what issues I faced, what things you might need to consider during the installation and setup process.

Partitioning

I have a Lenovo Thinkpad Edge 11 laptop and I decided to deploy Arch Linux on it after my first impressive experiences on my desktop PC with Arch. Although there was a nicely installed recovery partition and an OEM Win7 Professional on my new office notebook I deleted everything and repartitioned its hard drive.

Now my partition table looks like this:

sda1 Primary /boot 256M ext4
sda2 Primary swap 256M swap
sda3 Extended (264G)
sda5 / 24G ext4
sda6 /home 237G ext4
sda4 Primary 33G fat32

I am not sure that using ext4 for my /boot partition was the wisest decision but I do not have any problem with it, I do not see any performance loss due to journaling (i.e. the whole partition is only 256M) and I assume that ext4 is mature enough not to leave any reliability leaks for standard use.

As you can see I reserved some space on the end of the drive to create a dual boot setup if one day it will be necessary but now I have been using my notebook for several months and I have not installed anything on this partition yet.
Instead I use a Win7 virtual machine running under Virtualbox for accessing Windows-only applications (MS Office, Nokia PC Suite, Olympus Studio, etc.). Let's talk about it later, now I would like to sum up the installation process:

Installation

I followed the Beginners' Guide and the whole setup procedure went pretty flawlessly. I used a usb stick as installation medium that I have created with dd on another Linux box. I had some minor issues during the installation but nothing serious, I could solve them easily:
  • Somehow the built-in partition manager (parted?) of the installation medium could not create the extended partitions I needed so I used the old and reliable fdisk command to create my partition table. During the installation process I only had to assign the mount points for my pre-created partitions.
  • As I remember well the wlan interface did not work during installation so I used eth0 and I set up the wireless networking after installation.
I went through the package list of base and base-devel categories at the ending part of the installation and I tried to choose only those packages I thought would be useful. My philosophy is not to install anything that I don't need so I did not install packages that I did not know what they were meant for, only those I knew and among them only those that I needed.

/etc/rc.conf

I put my basic settings to /etc/rc.conf as per the Beginners' Guide according to my preferences, no tricks here. The MODULES and DAEMONS sections have changed a lot since I installed some tools. I will publish my actual configuration later.

/etc/fstab

I set up my /etc/fstab to mount my file system at boot time:

tmpfs /tmp tmpfs nodev,nosuid 0 0
devpts /dev/pts devpts defaults 0 0
shm /dev/shm tmpfs nodev,nosuid 0 0
UUID=0bcacd6c-8824-4961-bdeb-1ac6f3a94e70 swap swap defaults 0 0
UUID=7cca4b59-e71b-4f35-b3de-7eefc813a576 / ext4 defaults 0 1
UUID=c43fcb5b-c9e6-4a5f-8dda-85bda0f1b3c0 /home ext4 defaults 0 2
UUID=ec7151f4-50af-493a-b479-1722e569dd50 /boot ext4 defaults 0 2


I don't know if devpts and shm are needed or not, they are not very well documented, but I left those lines in the fstab that was created automatically during the installation.

I fulfilled the following settings according to the fstab wiki:

I inserted the tmpfs line (see the first row of my /etc/fstab). Now I am trying these symbolic links as they can improve some performance, at least theoretically:

ln -sf /run/lock /var/lock
ln -sf /run /var/run
reboot

I have set the fsck check priority (i.e. the file system check at every x boots) by the last flag of the /etc/fstab: I set my root (/) partition to be checked first (1), my /home and /boot secondly (2), and all the others are left unchecked (0) by fsck. I need to mention here that ext4 is checked extremely fast compared to ext3 so it seems to be a wise decision to use this file system.

You may have noticed that my /boot partition is in my fstab. Usually it is not needed because the files here do not change frequently. Although at a kernel upgrade (by pacman -Syu) your /boot partition needs to be mounted.

Other settings

I did not change anything in /etc/mkinitcpo.conf.
After installation my /etc/hosts file was correctly set up and since I use dhcp I did not need to change /etc/resolf.conf either.

In /etc/locale.gen I activated my Hungarian locales besides the default English ones:

en_US.UTF-8 UTF-8
en_US ISO-8859-1
hu_HU.UTF-8 UTF-8
hu_HU ISO-8859-2

Bootloader settings (/boot/grub/menu.lst):

I installed GRUB as my bootloader with these settings in my /boot/grub/menu.lst:

timeout 1
default 0

# (0) Arch Linux
title Arch Linux
root (hd0,0)
kernel /vmlinuz-linux root=/dev/disk/by-uuid/7cca4b59-e71b-4f35-b3de-7eefc813a576 ro
initrd /initramfs-linux.img

# (1) Arch Linux
title Arch Linux Fallback
root (hd0,0)
kernel /vmlinuz-linux root=/dev/disk/by-uuid/7cca4b59-e71b-4f35-b3de-7eefc813a576 ro
initrd /initramfs-linux-fallback.img

Please note that since kernel 3.0 the .img and kernel names have changed. On the new installation media of 2011.08.19 this will not be an issue any more. If you upgraded your kernel from the older (kernel26) version like me, you can find symlinks to the new files under /boot so your older version of menu.lst will still work. I changed these entries in my menu.lst in order to avoid the symlinks and using the real filenames instead as you can see in my menu.lst file.