View previous topic :: View next topic |
Author |
Message |
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3925
|
Posted: Thu May 21, 2020 1:36 pm Post subject: Gentoo dual init openrc/systemd |
|
|
Hi Guys,
Recently I experimented with creating a dual init Gentoo using both systemd and/or openrc for init system.
I was moderately successful and was amazed at how easy it was.
In my case it is working smoothly.
But please proceed on your own risk.
IMPORTANT:While starting this task from an already installed openrc system works flawlessly I recently found out that the opposite namely sytemd->openrc/systemd dual has glitches while booting openrc.Namely errors about no permissions to set cgroup something something.I am still searching as to why this is happening in this case...Probably some missing package or disabled openrc service...
These are the steps I took:
1. IMPORTANT: Have a system you can afford to spare and shed tears for if something goes sour.
2. If you start from an openrc system edit make.conf and add
Code: |
USE="....systemd -consolekit -elogind warmstarts"
|
Then run
Code: |
emerge -uDNav @world
emerge --noreplace openrc opentmpfiles
emerge -a --depclean
|
You will get an error about
Code: |
sys-apps/systemd is blocking sys-apps/sysvinit
|
To overcome this add the following in
/etc/portage/profile/package.provided
Code: |
sys-apps/sysvinit-<version>
|
and rerun emerge.
It will work this time.
This will pull systemd and dependencies and HOPEFULLY it will run smoothly.
If not then you might need some manual emerge intervention according to
https://wiki.gentoo.org/wiki/Systemd
Please read and apply carefully all the steps with the most important being:
Code: |
systemd-machine-id-setup
gpasswd --add <user> systemd-journal
systemctl preset-all
|
Now when it comes to choosing your next boot init system(openrc or systemd) you could theoretically add in /etc/default/grub
Code: |
GRUB_CMDLINE_LINUX="...init=/sbin/opentc-init OR init=/lib/systemd/systemd" AND
grub-mkconfig -o /boot/grub/grub.cfg
|
BUT systemd is arrogant and it will override grub settings to boot into itself no matter what.
The only way to prevent it from doing so is to make the /lib/systemd/systemd binary unavailable by renaming it.
So this is a quick and easy script to do precisesly this:
Code: |
#!/bin/bash
case $1 in
"systemd")
[ ! -f /lib/systemd/systemd.bak ] && mv /lib/systemd/systemd /lib/systemd/systemd.bak
ln -sf /lib/systemd/systemd.bak /lib/systemd/systemd
ln -sf /lib/systemd/systemd /sbin/init
;;
"openrc")
[ ! -f /lib/systemd/systemd.bak ] && mv /lib/systemd/systemd /lib/systemd/systemd.bak
rm /lib/systemd/systemd 2> /dev/null
ln -sf /sbin/openrc-init /sbin/init
;;
"status")
if openrc > /dev/null 2>&1
then echo "CURRENT INIT OPENRC"
else echo "CURRENT INIT SYSTEMD"
fi
if ls -l /sbin/init | grep openrc > /dev/null
then echo "NEXT INIT OPENRC"
else echo "NEXT INIT SYSTEMD"
fi
;;
*)
echo "USAGE:<myinit systemd|openrc|status>"
;;
esac
|
Please make it executable and move it to /usr/local/bin/myinit.
4. Please modify your .xinitrc to work with consolekit.In my case
Code: |
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session xfce4-session
|
5. If you are starting this transformation from a systemd system then please omit steps 1.and 2. and start from 3.
6. Please run "myinit <openrc|systemd|status>" to choose the init of your next boot.
7.commnet out any uncommented lines in
Code: |
/usr/lib/tmpfiles.d/journal-nocow.conf
|
This is meant to supress some trivial error messages when booting into openrc.
FINALLY
8. If you are booting into openrc you will find that "poweroff" and "reboot" commands do NOT work because there is no "sys-apps/sysvinit" installed in your system now.Instead please use
Code: |
openrc-shutdown -r now ### for REBOOTing and
openrc-shutdown -p now ### for POWEROFF
|
9. Next time that there is an update of "sys-apps/sysvinit" append this in "/etc/portage/profile/package.provided" as shown in step 3.
That's it really!!
Very easy.
I would love to have your feedback insights or suggestions about this.And also any caveats I failed to foresee..
Thanks a lot
|
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3925
|
Posted: Mon Jan 11, 2021 11:19 pm Post subject: |
|
|
Hi Guys ,
After a long time a gave a try to a dual openrc/systemd install starting from a minimal openbox system that i have laying on my disk,regularly updated though.
I was apprehensive if it was going to work since there is no cosolekit available now to use for openrc DE.
AMAZINGLY both systems AND open rc work perfectly and even openrc with NO consolekit or elogind was warking smoothly with the
/run/user/1000
directory created.
I was even able to have sound via pulseaudio.
So I was wondering how is that possible?
What created the /run/user/1000
directory.
I wonder if it is going to be as smooth if i install xfce.
I was not worried about the DE in systemd but rather in openrc.
in vain.......
_________________
|
|
Back to top |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Mon Jan 11, 2021 11:56 pm Post subject: |
|
|
Code: | ~ $ ls -l /run/user
ls: cannot access '/run/user': No such file or directory
| Must be systemd |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3925
|
Posted: Tue Jan 12, 2021 12:07 am Post subject: |
|
|
@Tony0945
But how is this possible when in openrc environment.
Yet again /run is on tmpfs no?
So even if systemd created it would be gone @reboot no?
Is it possible that systemd-logind is running in openrc.
Kindly give me a minute to check it out...
EDIT
Yes I am now running in openrc.
systemctl gives an output of
Failed to list units: Launch helper exited with unknown return code 1
systemd-ligind is nowhere to be seen
/run/user/1000
is not present now.
but everything seem to work just fine even pulseaudio(tested it in youtube).
I reboot or shutdown the system from the terminal using
openrc-shutdown
commands.
It is smooth
Ah and it works with xfce also.Just checked.
_________________
|
|
Back to top |
|
|
|