Systemd is a framework responsible to manage services/daemons and start up scripts in Linux based Desktop Distributions and is a replacement for Init.
What is cool about it, except all the tech facts, is that Systemd provides a very simple interface to handle some services in Linux.
Distros with Systemd
Distros are known to me that using Systemd is Fedora, OpenSUSE, latest Arch, Mageia 3 and all the derivatives of those. Distros that don’t use Systemd are Ubuntu and all derivatives. I don’t know about Debian, but I think you can install it there, something you can’t do in Ubuntu.
Although GNOME makes a heavy use of Systemd, isn’t a dependency.
Weird Systemd fact!
Systemd was created in 2010 by the very famous OS programmers Lennart Poettering (Red Hat) and Kay Sievers (was at SUSE/Novell at that time -if I am not wrong-, Red Hat now) and is part of the FreeDesktop. At FOSDEM 2011 Lennard said in an interview:
Systemd is the first Linux init system which allows you to properly kill a service.
Surprised by this statement? Rightly so, but it is true. Properly killing a daemon on Linux is really hard and without systemd actually almost impossible to do correctly. (No, a simple “killall httpd” is due to many reasons unsuitable to kill Apache) If you want to know why I say that and what systemd does differently here, then make sure to attend my talk and ask me about it!
Speed Up booting times
The first task is to try to speed our GNOME boot time, by disabling some needless services. To measure the times of each service we can use <systemd-analyze>. If you don’t have it you can install it by
$ sudo yum install systemd-analyze
Of course you have to replace Fedora’s Yum to your Distro update manager. After installation you can run:
And this is my output. Pretty much that means that to get from Grub to my GDM GNOME Login Screen with all services loaded I need around 10″.
Startup finished in 2851ms (kernel) + 1334ms (initrd) + 5654ms (userspace) = 9840ms
Your numbers here can be quite different. Lets see why
$ systemd-analyze blame
Will give us a more detailed view in what happens to each service
693ms akmods.service 558ms plymouth-start.service 515ms systemd-udev-settle.service 391ms firewalld.service 254ms iscsid.service 234ms systemd-logind.service 233ms chronyd.service 229ms rtkit-daemon.service 222ms mcelog.service 215ms avahi-daemon.service 205ms fedora-loadmodules.service 202ms abrt-ccpp.service 194ms ksm.service 191ms accounts-daemon.service 185ms abrt-vmcore.service 177ms restorecond.service 174ms systemd-udev-trigger.service 165ms multipathd.service ........
Akmods.service takes so much to load and I don’t even need it since I have kmod. I also don’t need Plymouth and maybe you don’t need firewalld. Speaking of firewalld I have seen in a blog that the author recommends to completely remove it as there is no way to shut it down. Well, there is.
Disabling Services with Systemd is quite easy. For example for firewalld.
sudo systemctl stop firewalld.service //Stop it
sudo systemctl disable firewalld.service //Remove it from start up
This way by disabling some services you can achieve some better boot times, but you can also make a faster system overall. If you want to go into deeper modifications and insane bootup times you might want to check “Fedora 17 Boot Optimization (from 15 to 2.5 seconds)” great article from Harald Hoyer.
If you are willing to follow this guide, make sure you have a Live Image of your distro next to you, so you can restore your system in case that something goes wrong.
By the way if you wish to completely disable SELinux, which probably you don’t need in a normal home installation just:
$ sudo gedit /etc/selinux/config
and follow the options there.
There are many useful things you can do with Systemd, and the best part is that you don’t need to write any code. I will attach the sources you can read more, but lets have a quick view of it.
Activates a service immediately:
$ sudo systemctl start foo.service
Deactivates a service immediately:
$ sudo systemctl stop foo.service
Restarts a service:
$ sudo systemctl restart foo.service
Shows status of a service including whether it is running or not:
$ sudo systemctl status foo.service
Enables a service to be started on bootup:
$ sudo systemctl enable foo.service
Disables a service to not start during bootup:
$ sudo systemctl disable foo.service
Check whether a service is already enabled or not:
$ sudo systemctl is-enabled foo.service; echo $?
0 indicates that it is enabled, and 1 indicates that it is disabled. In Fedora 17, in addition to the return code, “enabled” or “disabled” will be printed to stdout.
Systemd also support <service>. So instead of
$ sudo systemctl start foo.service
You can use
$ sudo service foo start
Since Systemd 195 (present in Fedora 18) you can replace foo.service with foo.
$ sudo systemctl start foo
Creating a Plot Diagram
If you have installed <systemd-analyze> you can run:
$ systemd-analyze plot > plot.svg
$ eog plot.svg
That is a bit confusing to me, it seems there is there are two packages. <systemd-gtk> or <systemd-ui> depending on the distro. In Fedora 18 is the second one. Install it
$ sudo yum install systemd-ui
Systemd User Interface is not yet ready and it isn’t recommended for production use.
You will find much more on the bellow links. Systemd is not just for admins, it is a worth to give a look at it. I am not someone that I fancy the idea that a Linux User should know lot of things for its box, but Systemd can be proven really useful to anyone.