2014-04-06

Setting up Systemd on Debian in 10 minutes

Recently I've been reading more and more about Systemd. Now, most distros have already moved to Systemd but I'm using Debian and was stuck with init which was the default. Given the recent discussion on the Debian mailing lists about migrating to systemd as the new default, I was even more inclined to make the switch now and get used to it before it's forced upon us.

Actually I was really looking forward to it, but as Linux goes I was expecting it to be a pain, so I was pleasantly surprised that it only took me 10 minutes and wasn't a hassle at all.

I've decided to document the steps I've taken in case that someone finds it useful.

First some prerequisites, make sure that you've got your system up2date.

sudo apt-get update && sudo apt-get upgrade

Make sure systemd is actually installed (it should be but check anyway):

sudo apt-get install systemd

Before you switch permanently it's recommended that you try a one-time-boot with systemd just to see if everything's okay. Reboot your machine and on the grub screen selected the kernel you wish to boot and press e. Then at the end of the kernel line add init=/bin/systemd and boot your machine. If everything is fine continue with making systemd a permanent choice.

The recommended way to replace init with systemd is to install the package systemd-sysv which takes care of everything.

sudo apt-get install systemd-sysv

Edit /etc/default/grub and add init=/bin/systemd at the end of the line GRUB_CMDLINE_LINUX_DEFAULT. Save the file and run the following command to update grub:

sudo update-grub2

Reboot and you should be running systemd (use ps aux and check for PID 1).

One last thing with Debian is to set up peristent logging with systemd's logging component called journal. By default journal will log to /run which is ephemeral meaning the logs will disappear after reboot. The process of making the logs persistent (if you choose to do so) is documented here: /usr/share/doc/systemd/README.Debian Basically you just need to run this:

install -d -g systemd-journal /var/log/journal
setfacl -R -nm g:adm:rx,d:g:adm:rx /var/log/journal

It's worth noting that you don't have to use journal if you don't want to, it's designed to co-exist with syslog, that's already running on your system, so you can continue to use that. I personally find journal awesome and would recommend that you at least check it out and see what it brings to the table.

And that's it folks, now go read more stuff about systemd here.

Thanks to babilen on irc.oftc.net for taking the time and explaining everything patiently :).

linux systemd init debian

Comments powered by Disqus