Setting up Systemd on Debian in 10 minutes

本文介绍如何在10分钟内将Debian系统的启动方式从传统的init切换到Systemd,并配置持久的日志记录。文章详细描述了更新系统、安装Systemd、临时启动测试及永久更改默认启动方式等步骤。

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 with init which was the default. Given the recentdiscussion on the Debian mailing lists about migrating to systemd 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 with systemd just to seeif everything's okay. Reboot your machine and on the grub screen selected the kernel you wish to bootand 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-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 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 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/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'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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值