Monday, March 5, 2012

Correcting broken startup of rsyslogd in a systemd unit file

My Fedora 17 Beefy Miracle alpha1 ARM system does not any contents in /var/log/messages. This is very impractical for troubleshooting. The command systemd-journalctl --no-tail shows that rsyslog.service fails to start correctly. Bummer!

Starting the daemon by hand, does not give any issues, so at least rsyslogd does not have an issue itself.

Checking the configuration, there are two unit files that may be used to start rsyslogd:
  1. /etc/systemd/system/syslog.service
  2. /etc/systemd/system/multi-user.target.wants/rsyslog.service
Both of these are symlinks to the unit file (/usr/lib/systemd/system/rsyslog.service) that comes with the rsyslogd package:
[Unit]
Description=System Logging Service

[Service]
EnvironmentFile=-/etc/sysconfig/rsyslog
ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service
ExecStart=/sbin/rsyslogd -n $SYSLOGD_OPTIONS
Sockets=syslog.socket
StandardOutput=null

[Install]
WantedBy=multi-user.target
All looks pretty neat, there is no very obvious issue here. However, on checking what this systemd-kmsg-syslogd.service is and does, I seem to be unable to find the unit file that defines this service. Just guessing, but if the ExecStartPre fails, it may not even try to start the rsyslog-daemon. Just commenting out the ExecStartPre is Not Done with the systemd configuration files. The advised way to change unit files which live under /usr/lib/systemd should be copied to the /etc/systemd/* directories instead:
# cd /etc/systemd/system
# rm syslog.service
# ln -s /usr/lib/systemd/system/rsyslog.service syslog.service
# cd multi-user.target.wants
# rm rsyslog.service
# ln -s ../syslog.service rsyslog.service
Now is is possible to change the unit file, without changing a file that may be replaced by a update of the rsyslog package. Commenting out the ExecStartPre in the new copy of syslog.service and rebooting, makes syslog work for me and /var/log/messages contains all the logs as expected.

More brokenness in my systemd configuration

One more annoying thing is that systemctl is not very usable:
# systemctl status rsyslog.service
Failed to get D-Bus connection: No connection to service manager.
Although D-Bus is running:
# ps v -C dbus-daemon
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 1474 ?        Ss     0:00      6   265  2770  1436  0.3 /bin/dbus-daemon --system --address=systemd: --nofork --systemd-activation

I'm not sure what causes that (SElinux is disabled), but it is currently no big issue for me.

Saturday, March 3, 2012

WLAN configuration of NetworkManager from the console

It seems that configuring a WLAN connection in NetworkManager on Fedora (tested on F17 alpha on ARM) is pretty straight forward. Unfortunately I was not able to find documentation about the steps, so I just note them down here:

I must confess, that I cheated a little, as the configuration was initially created with nm-connection-editor by selecting the 'Available to all users' option. Copying the configuration files to the Fedora 17 rootfs image made my wireless work immediately.

The configuration consists out of two files:

  1. /etc/sysconfig/network-scripts/ifcfg-MyWLAN where MyWLAN is just a name for your connection
    ESSID="MyESSID"
    MODE=Managed
    KEY_MGMT=WPA-PSK
    TYPE=Wireless
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME=MyWLAN
    UUID=57fc7596-af3e-48af-8d90-1a06783083d7
    ONBOOT=yes
    PEERDNS=yes
    PEERROUTES=yes
    
    Of course it is needed to change at least the NAME and the ESSID. KEY_MGMT can probably have other values, but there is no need for me to research that atm.
  2. /etc/sysconfig/network-scripts/keys-MyWLAN
    WPA_PSK="My Top Secret Password"
    
    This password will likely not work anywhere, just change it to whatever is needed.

After putting these two files in place (copied from an other device after booting) made NetworkManager connect to the WLAN immediately.

Some tools for checking the connection are:
  • nm-tool which displays the detected networks and some more details.
  • nmcli con up MyWLAN in case you want to force connecting to the WLAN configured under /etc/sysconfig/network-scripts/ifcfg-MyWLAN.