Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
anyone using s6 init?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Sun Aug 09, 2020 5:46 pm    Post subject: anyone using s6 init? Reply with quote

Im having problems i installed s6-linux-init and s6 but it doenst work. i installed s6-linux-init 1.0.3.1 and s6 2.9.0.1 , all i got is
Code:
execlineb fatal unable to exec /sbin/getty no such file or directroy

i followed this guide
Install all the s6-linux-init dependencies:

skalibs
execline
s6

Save and remove your old /etc/s6-linux-init directory, if you have one.
Install s6-linux-init itself.
Save your old /sbin/init, /sbin/telinit, /sbin/shutdown, /sbin/halt, /sbin/poweroff and /sbin/reboot binaries.
Make sure you have a /run directory.
Edit the scripts in /etc/s6-linux-init/skel.
Check that your devtmpfs is automounted by your kernel at boot time. If it is not, add the -d /dev option to the s6-linux-init-maker command line below.
As root, run:

rm -rf /tmp/blah
s6-linux-init-maker -1 -G "/sbin/getty 38400 tty1" /tmp/blah
rm -rf /etc/s6-linux-init/current
mv /tmp/blah /etc/s6-linux-init/current
cp -a /etc/s6-linux-init/current/bin/* /sbin/
.
i think im seting wrong the stage1 and stage two of this init.
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Sun Aug 09, 2020 6:31 pm    Post subject: Re: anyone using s6 init? Reply with quote

adcdam wrote:
[...] all i got is
Code:
execlineb fatal unable to exec /sbin/getty no such file or directroy
Yes. Gentoo has no /sbin/getty. It has /sbin/agetty (from sys-apps/util-linux).

adcdam wrote:
Check that your devtmpfs is automounted by your kernel at boot time. If it is not, add the -d /dev option to the s6-linux-init-maker command line below.
And have you checked that you don't need -d?

adcdam wrote:
s6-linux-init-maker -1 -G "/sbin/getty 38400 tty1" /tmp/blah
s6-linux-init's default PATH is only /usr/bin:/bin. For Gentoo, you problably want something like sys-apps/baselayout's ROOTPATH value, passed with a -p option:
Code:
-p "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"

adcdam wrote:
Save your old /sbin/init, /sbin/telinit, /sbin/shutdown, /sbin/halt, /sbin/poweroff and /sbin/reboot binaries.
[...]
cp -a /etc/s6-linux-init/current/bin/* /sbin/
On Gentoo, if you started from a sysvinit + OpenRC setup, that is going to make Portage's database inconsistent: /sbin/{halt,init,poweroff,reboot,shutdown,telinit} belong to sys-apps/sysvinit, and you are replacing them with s6-linux-init-maker's scripts.

adcdam wrote:
Edit the scripts in /etc/s6-linux-init/skel.
And how did you edit them exactly? The example ones contain only comments, so they do nothing.

But more importantly, what were you expecting to use as the computer's rc subsystem? There's no mention in your post of s6-rc, of s6-rc service definitions and where you are going to get them, or of any other service manager.


Last edited by GDH-gentoo on Mon Aug 10, 2020 1:14 am; edited 2 times in total
Back to top
View user's profile Send private message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Sun Aug 09, 2020 7:04 pm    Post subject: Reply with quote

yes i was stupid enough that i didnt notice about getty, i did
Code:
sudo s6-linux-init-maker -1 -G "/sbin/agetty 38400 tty1" /tmp/blah

i was not using open-rc i was using runit
now the kernel boot
but i can t log in.
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Sun Aug 09, 2020 7:14 pm    Post subject: Reply with quote

adcdam wrote:
yes i was stupid enough that i didnt notice about getty, [...]
now the kernel boot
but i can t log in.

Good. Now answer the rest of the questions in my post :) Especially this one:

GDH-gentoo wrote:
adcdam wrote:
Edit the scripts in /etc/s6-linux-init/skel.
And how did you edit them exactly? The example ones contain only comments, so they do nothing.
Back to top
View user's profile Send private message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Sun Aug 09, 2020 7:19 pm    Post subject: i sent you a private message Reply with quote

read the private message.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15832

PostPosted: Sun Aug 09, 2020 7:39 pm    Post subject: Reply with quote

Please answer those questions publicly. We can't read GDH-gentoo's private messages. As is, you can only get help from one person because the rest of us cannot see the relevant information.
Back to top
View user's profile Send private message
etnull
Guru
Guru


Joined: 26 Mar 2019
Posts: 369
Location: Russia

PostPosted: Sun Aug 09, 2020 10:52 pm    Post subject: Reply with quote

Plus the information can be useful to other users (even me in the future). No reason to hold it private. This is not a chat room.
Back to top
View user's profile Send private message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Mon Aug 10, 2020 2:09 am    Post subject: Reply with quote

when i have s6 working as it should i ll post bout it.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 4014
Location: Illinois, USA

PostPosted: Mon Aug 10, 2020 3:34 am    Post subject: Reply with quote

I am puzzled why you postee in the first place if you don't want to describe it.
Do you feel you did something foolish? we all do sometime. And yes, there are experienced people using s6. Not I. I use very old OpenRC, but there are quite a few experienced people who do. I'm just reading to learn.
Back to top
View user's profile Send private message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Mon Aug 10, 2020 4:44 am    Post subject: Reply with quote

I posted here asking for help or guide, that s why i posted, i got more questions than answers, there are experienced people using s6 as you said perhaps they can post a guide on how to make it work in a easier way than this guide explain https://wiki.gentoo.org/wiki/S6_and_s6-rc-based_init_system#stage1 and this https://wiki.gentoo.org/wiki/S6 with examples on where would be the best place to put the scan dir, how to edit the scrips etc...
Sometimes the best way is give some examples and yes i did something stupid if i had done it in the right way i would t be here asking for help on how to make my system work with s6, i have runit installed but i find it much much easier.


edit1: My bad the problem is i didnt take the time to read all the documentation, is my fault, the documentaction is very complete i was just a little impatient and wanted to have all set in 5 minutes, and some times you just have to take your time to read all carefully, sorry.
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Mon Aug 10, 2020 4:54 pm    Post subject: Reply with quote

For a distribution, I would never set up an s6-based init system without the one software package that was not mentioned in the OP: the service manager, s6-rc. And for that, you need to give service definitions to s6-rc-compile, to tell s6-rc what to do. They are like the /etc/init.d/* and /etc/conf.d/* files for OpenRC, or the unit files for systemd. And this aspect distinguishes init systems between supported ones and unsupported ones. When a distribution supports an init system, it provides packages that contain all needed service definitions, likely according to some specific policy.

On Gentoo, s6-based init systems are unsupported, just like runit as init system. This means, as I said in other threads, that you have to write the service definitions yourself, or get them from somewhere else, possibly with some adaptation, and then self-maintain them. And that's the reason why there can't really be a guide with fixed, simple steps for installing s6 on Gentoo as an init system. At some point, such a document would just have to say "now go find service definitions and install them".

Now, if you do have a set of service definitions that suit your needs, then it could be possible to give advice on how to set that up.

EDIT to add: I could add some opinions, though.

1) I don't consider a good idea to change or replace files owned by a distribution package. And in this case, this applies to /sbin/init, /sbin/telinit, /sbin/shutdown, /sbin/halt, /sbin/poweroff and /sbin/reboot. I would simply use s6-linux-init-shutdown or s6-linux-init-telinit (if you even want runlevels) directly. If you look at the scripts generated by s6-linux-init-maker, they are just simple execline wrappers around those programs. For /sbin/init, I'd just install an execline script in /sbin with any name other than 'init' (e.g. /sbin/gentoo-s6-init), and just configure the bootloader to pass an init= parameter in the kernel command line. Something like:

/sbin/gentoo-s6-init
Code:
#!/bin/execlineb -S0
s6-linux-init
-c /etc/s6-linux-init/current
-p /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
-d /dev # if you need it
# Other s6-linux-init options you might want
$@
/boot/grub/grub.cfg
Code:
menuentry 'Gentoo Linux <kernel version> (with sysvinit + OpenRC)' $menuentry_id_option 'XXX' {
        # ...
        linux /vmlinuz-<kernel version> <kernel command line>
}
menuentry 'Gentoo Linux <same kernel version> (with runit)' $menuentry_id_option 'YYY' {
        # ...
        linux /vmlinuz-<same kernel version> <same kernel command line> init=/sbin/runit-init
}
menuentry 'Gentoo Linux <same kernel version> (with s6 + s6-rc + s6-linux-init)' $menuentry_id_option 'ZZZ' {
        # ...
        linux /vmlinuz-<same kernel version> <same kernel command line> init=/sbin/gentoo-s6-init -- <stage1 init arguments>
}

2) If you have runit service directories, they can be easily converted to s6-rc longrun definitions. Runit and s6 service directories are similar (i.e. daemontools-style), and s6-rc longrun definitions are similar to s6 service directories. However, since runit setups usually lack a service manager, the run and finish files can contain boilerplate to deal with dependencies and other service-manager-like stuff, that with s6-rc could be removed in favor of e.g. just naming services in a dependencies file.

3) Runit is known for the 'oneshots before longruns' restriction of its model. I suppose you could turn /etc/runit/{1,3} files that are known to work into one big s6-rc oneshot that every other service depends on, but that would not be very optimal.
Back to top
View user's profile Send private message
adcdam
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2015
Posts: 144

PostPosted: Mon Aug 10, 2020 7:19 pm    Post subject: Reply with quote

Thanks ,i have s6-rc installed and thats what i was thinking to use the scrips of runit that i have.
Thanks a lot!
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Thu Aug 13, 2020 2:59 pm    Post subject: Reply with quote

adcdam wrote:
[...] and thats what i was thinking to use the scrips of runit that i have.

It turns out that these are coming from the powerman overlay. This repository already provides /etc/runit/{1,2,3} files and runit service directories for several services. adcdam, the problem is that, to be able change init system, you'd have to migrate all of Alex's work to s6-rc. What I can do at most, is maybe show some conversion examples.

To summarize:

For an s6-based setup, the s6-linux-init program fills the role of the runit-init program. Normally, an execline wrapper script around it is used, as I showed in my previous post, to make it simpler to pass options to it.

/etc/runit/2 is probably universally a shell wrapper around an exec runsvdir command that starts the runit supervision tree. The file installed by power-misc/runit-scripts::powerman is no exception. No conversion is needed, because s6-svscan running as proces 1 fills its role. And no special setup is needed either, because s6-linux-init replaces itself with s6-svscan automatically when its work is done, and that starts the s6 supervision tree.

/etc/runit/1 and /etc/runit/3 from power-misc/runit-scripts::powerman, and all service directories installed by runit-service/service-*::powerman packages would be replaced by s6-rc services... which you currently do not have. That's the big, real work. If you had the definitions in source format stored in e.g. /home/adcdam/servicedef, then you would do s6-rc-compile database_pathname /home/adcdam/servicedef, where database_name would be the DB pathname expected by /etc/s6-linux-init/current/scripts/rc.init. That is /etc/s6-rc/compiled if you want to go with defaults.


Last edited by GDH-gentoo on Thu Aug 13, 2020 3:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Thu Aug 13, 2020 3:01 pm    Post subject: Reply with quote

Example #1 - longruns

As far as I can tell, runit-service/service-dbus::powerman installs this:

Code:
$ ls -F1 /etc/sv/dbus
finish*
log/
run*

$ ls -F1 /etc/sv/dbus/log
run*

A service with a dedicated logger like this can be converted to a pair of s6-rc longruns joined by a pipeline. Possible partial conversion:

Code:
$ ls -1 /home/adcdam/servicedef/dbus-main
finish
producer-for
run
type

$ cat /home/adcdam/servicedef/dbus-main/type
longrun

$ ls -1 /home/adcdam/servicedef/dbus-logger
consumer-for
pipeline-name
run
type

$ cat /home/adcdam/servicedef/dbus-logger/type
longrun

$ cat /home/adcdam/servicedef/dbus-main/producer-for
dbus-logger

$ cat /home/adcdam/servicedef/dbus-logger/consumer-for
dbus-main

$ cat /home/adcdam/servicedef/dbus-logger/pipeline-name
dbus

/etc/sv/dbus/{run,finish} have nothing runit-specific in them, so they could be used verbatim as /home/adcdam/servicedef/dbus-main/run and /home/adcdam/servicedef/dbus-main/finish, respectively. /etc/sv/dbus/log/run does have runit commands in it, though:
Code:
#!/bin/sh
exec &>/var/log/all/.log
exec chpst -u log svlogd -tt /var/log/dbus/*/
/var/log/dbus/all/config
Code:
n2

In that case, you can replace that with the equivalent commands from s6:

/home/adcdam/servicedef/dbus-logger/run
Code:
#!/bin/sh
exec &>/var/log/all/.log
exec s6-setuidgid log \
s6-log T n2 /var/log/dbus/*/
and remove /var/log/dbus/all/config. Or, if you prefer execline:
Code:
#!/bin/execlineb -P
redirfd -w 1 /var/log/all/.log
fdmove -c 2 1
s6-setuidgid log
elglob logdirs /var/log/dbus/*/
s6-log T n2 $logdirs

This conversion is partial, because you can add more files to enable more s6-rc functionality. In particular, since dbus-daemon is in /usr, and the logger logs to /var, you'll likely want a dependencies file that specifies the name of a service that mounts the filesystems. File pipeline-name creates a service bundle named 'dbus' that contains both dbus-main and dbus-logger.

The runit setup satisfies the dependency by mounting filesystems in /etc/runit/1, which runs and finishes before supervision tree processes start, i.e. the 'oneshots before longruns' effect.
Back to top
View user's profile Send private message
GDH-gentoo
Guru
Guru


Joined: 20 Jul 2019
Posts: 458
Location: South America

PostPosted: Thu Aug 13, 2020 10:46 pm    Post subject: Reply with quote

Example #2 - oneshots

As far as I can tell, /etc/runit/1 from power-misc/runit-scripts::powerman contains:
Code:
#!/bin/bash
#...
LOCALMOUNT() {
   mount -at noproc,noafs,nocifs,nocoda,nodavfs,nofuse,nofuse.sshfs,nogfs,noglusterfs,nolustre,noncpfs,nonfs,nonfs4,noocfs2,noshfs,nosmbfs -O no_netdev
   swapon -a
}
#...
SOUND() {
   alsactl -f /etc/asound.state restore && touch /run/init.alsa
}
#...
. /etc/runit/lib.sh
#...
try LOCALMOUNT
#...
#try SOUND      # Enable this if you have sound card (also in /etc/runit/3!)

and /etc/runit/3 contains:
Code:
#!/bin/bash
#...
SOUND() {
    test -f /run/init.alsa && alsactl -f /etc/asound.state store
}
#...
. /etc/runit/lib.sh
#...
#try SOUND      # Enable this if you have sound card

Those parts could be converted to a pair of s6-rc oneshots. Suitable dependencies must be specified because s6-rc does everything it can in parallel, and you will certainly not want races. Possible partial conversion:

Code:
$ ls -1 /home/adcdam/servicedef/localmount
dependencies
type
up

$ cat /home/adcdam/servicedef/localmount/type
oneshot

$ cat /home/adcdam/servicedef/localmount/up
/etc/s6-rc/service-data/localmount

$ ls -1 /home/adcdam/servicedef/sound
dependencies
down
type
up

$ cat /home/adcdam/servicedef/sound/type
oneshot

$ cat /home/adcdam/servicedef/sound/up
/etc/s6-rc/service-data/sound/up

$ cat /home/adcdam/servicedef/sound/down
/etc/s6-rc/service-data/sound/down

$ cat /home/adcdam/servicedef/sound/dependencies
localmount

/etc/s6-rc/service-data/localmount
Code:
#!/bin/bash
LOCALMOUNT() {
   mount -at noproc,noafs,nocifs,nocoda,nodavfs,nofuse,nofuse.sshfs,nogfs,noglusterfs,nolustre,noncpfs,nonfs,nonfs4,noocfs2,noshfs,nosmbfs -O no_netdev
   swapon -a
}
. /etc/s6-rc/service-data/lib.sh
try LOCALMOUNT

/etc/s6-rc/service-data/sound/up
Code:
#!/bin/bash
SOUND() {
   alsactl -f /etc/asound.state restore && touch /run/init.alsa
}
. /etc/s6-rc/service-data/lib.sh
try SOUND

/etc/s6-rc/service-data/sound/down
Code:
#!/bin/bash
SOUND() {
    test -f /run/init.alsa && alsactl -f /etc/asound.state store
}
. /etc/s6-rc/service-data/lib.sh
try SOUND

/etc/s6-rc/service-data/lib.sh can be a copy of /etc/runit/lib.sh, and the try() function defined in it should be edited to just exit with a nonzero code in the failure case, instead of calling emergency(). Service 'sound' should depend on service 'localmount' because alsactl is in /usr. The dependencies file of 'localmount' should name all services that must be in up state before executing the LOCALMOUNT() function. There is no down file because filesystems are unmounted by the s6-linux-init-umountall program, which is automatically called by the shutdown daemon, so no need to define an s6-rc service that does that.

For the runit setup, /etc/runit/1 is a single script, so actions happen serially, and dependencies are satisfied by ordering the commands correctly.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum