systemd -> openRC
Recently I switched from systemd to openRC on my Gentoo laptop.
最近我把我践兔的笔记本高头的 systemd 换到了 openRC。
Why?为什么啊?
Contrast to what you might think, this article would not do a comparison between systemd and openRC.
I switched purely for fun.
没得想到吧,这篇文章不搞 systemd 跟 openRC 的对比。我纯粹为了好玩。
Steps步骤
First update the whole system, as it is a good practice before doing any invasive change.
首先更新整个系统。在搞任何侵入性的修改之前,这么搞总是好的。
1 | eix-sync |
Then switch to a non-systemd profile.
然后切到一个不是 systemd 的 profile。
1 | eselect profile list |
Change
USE="elogind -systemd"
in make.conf.在 make.conf 里头,改个
USE="elogind -systemd"
。I first tried to do the same as updating the system, but it still does not rid me of the systemd dependencies.
So check now what packages still have a hard-dependency on systemd.
我先试到搞跟更新系统的时候一样的事情,但是它还是没得办法把我从 systemd 依赖里头解脱出来。
所以现在检查一下哪些包还对 systemd 有硬依赖的。
1 | ] equery d systemd |
It turns out that
virtual/logger
, virtual/service-manager
, virtual/tmpfiles
have dependencies on systemd, and
they are not willing to switch to another provider. I had to pull them in manually. Here, I chose openrc
for service-manager
(obviously), systemd-tmpfiles
for tmpfiles
(only other sensible package to provide this), and syslog-ng
for logger
(this one has many choices).看样子
virtual/logger
、virtual/service-manager
、virtual/tmpfiles
有 systemd 的依赖,而且这些都不愿意切换到另一个
提供者的。我就得把这些手动拉进来了。在这块,我选了 openrc
来提供 service-manager
(显然),systemd-tmpfiles
来提供
tmpfiles
(唯一的别的提供这玩意儿的理智的包),然后是 syslog-ng
来提供 logger
(这个就有蛮多选择的了)。1 | emerge -av1uUD --with-bdeps=y openrc systemd-tmpfiles sysvinit syslog-ng world |
In the meantime, prepare other parts of the system for openRC.
First backup the current kernel (bzImage, System.map and initramfs), and check the kernel config
to make sure we supported openRC.
与此同时,把系统的别的地方给 openRC 准备一下子。
首先备份一下当前的内核(bzImage、System.map 跟 initramfs),然后检查一下内核配置,确保支持了 openRC。
1 | Gentoo Linux ---> |
Bid farewell to systemd and express gratitude:
跟 systemd 讲再见,表达一下感谢:
1 | ] systemd-analyze |
Always good to have some root ttys and sessions:
有几个 root 的 tty 跟会话总是好的:
1 | sudo su - |
Install a busybox in case of misfortune.
装个 busybox 以防不测。
1 | euse -E static -p sys-apps/busybox |
After the
emerge
finished, I was prompted to run emerge @preserved-rebuild
so just ran it.emerge
结束之后,它提示我要运行 emerge @preserved-rebuild
,那就运行吧。Update the initramfs to pickup any changes. This may not be needed; I ran it just to be safe.
更新 initramfs 来捡起来任何更改。这个可能不需要,为了保险起见我还是执行了。
1 | genkernel --no-clean initramfs |
Configuration配置
1 | # cat /etc/timezone |
1 | # cat /etc/locale.gen |
1 | emerge -av app-admin/logrotate |
1 | # cat /etc/conf.d/hwclock |
NetworkManager
1 | rc-update add NetworkManager default |
Display manager显示管理器
1 | rc-update add display-manager default |
keymaps (replacement for localectl)keymaps(localectl的替代)
1 | nano -w /etc/conf.d/keymaps |
1 | # cat /etc/X11/xorg.conf.d/00-keyboard.conf |
lvm
Reference: https://wiki.gentoo.org/wiki/LVM#openrc
1 | rc-update add lvm boot |
tmpfs on /tmp (systemd auto-mount)在 /tmp 高头的 tmpfs(systemd 自动挂载的)
1 | # nano -w /etc/fstab |
backlight (replacement for systemd-backlight)backlight(systemd-backlight 的替代)
1 | eselect repository enable beatussum-overlay |
alsa
Note that the alsasound service only saves and loads mixer state. You will still be able to use sound without this service.
注意 alsasound 服务只是保存跟读取混音器的状态。就算不用这个服务,也可以用声音的。
1 | rc-update add alsasound default |
cron
1 | rc-update add cronie boot |
time sync (replacement for systemd-timesync)时间同步(systemd-timesync 的替代)
1 | emerge -av ntp |
https://wiki.gentoo.org/wiki/Ntp#Ntpd
ufw
1 | rc-update add ufw default |
bluetooth蓝牙
1 | rc-update add bluetooth |
Finalize完成
1 | # emerge -avuUD world |
But in fact after the reboot command it just hangs indefinitely. I ended up rebooting via sysrq.
但是实际上重启命令之后它就一直卡到那块了。我最后用 sysrq 重启的。
What's next?然后呢?
Nothing. What are you expecting?
没得唻。你在期待什么呢?