Setting up Systemd on Debian in 10 minutes

来源:互联网 发布:linux查看javahome 编辑:程序博客网 时间:2024/06/06 11:43

Recently I've been reading more and more about Systemd. Now, most distros have already moved toSystemd but I'm using Debian and was stuck withinit which was the default. Given the recentdiscussion on the Debian mailing lists about migrating tosystemd as the new default, I was even moreinclined 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 Iwas 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 withsystemd just to seeif everything's okay. Reboot your machine and on the grub screen selected the kernel you wish to bootand presse. 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-sysvwhich takes care of everything.

sudo apt-get install systemd-sysv

Edit /etc/default/grub and add init=/bin/systemd at the end of the lineGRUB_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 calledjournal.By default journal will log to /run which is ephemeral meaning the logs will disappear after reboot. The processof making the logs persistent (if you choose to do so) is documented here:/usr/share/doc/systemd/README.DebianBasically you just need to run this:

install -d -g systemd-journal /var/log/journalsetfacl -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'salready running on your system, so you can continue to use that. I personally find journal awesome and wouldrecommend 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 :).


https://denibertovic.com/posts/setting-up-systemd-on-debian-in-10-minutes/

0 0