troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
633 stars 63 forks source link

finit hangs at "Requesting subsystem events" #133

Closed firasuke closed 4 years ago

firasuke commented 4 years ago

I can't seem to get finit to work. It just hangs at "Requesting subsystem events" and regardless of what I put in /etc/finit.conf agetty just won't spawn /bin/login, and when I add debug to the kernel cmdline I get messages regarding /run/udev/queue Not being found or no such file or directory (I'm using eudev btw).

I've enabled the fallback shell, and was able to run the login program manually since agetty doesn't want to spawn /bin/login (even when using -l), and enter to my system with the shell I have inside it.

I'm unsure what to do now and how to debug it. I ran initctl log and was told that /var/log/syslog doesn't exist, so I created it, and the output is empty, any ideas?

troglobit commented 4 years ago

Many questions in one issue here. I'll try to answer them as broadly as possible.

  1. Finit has several requirements on the kernel, these are barely documented at all. I once created myLinux to serve as an example of how to build a Finit based system from scratch. The myLinux 1.x branch is the best to browse around in atm. (I'm rebuilding myLinux based on Buildroot on the main branch)
  2. The base "skeleton" for your system has requirements from both Finit, FHS, and various applications you want to run. E.g., /run/ today is either a separate ramdisk set up in /etc/fstab or a symlink to /var/run, depending on your distro. The FHS details more, in myLinux system/skeleton there's a base skeleton example.

Finit does not use udev, it only starts it at boot, if it can find it and it's relevant directories exist. (Them being missing is probably the reason for you first message.)

Finit comes with a built-in getty, use the examples in the docs to get it running, it calls /bin/login for each username that it's fed. When you have that running, getting agetty to run should be easier. (I've never tried that myself)

The initctl log SVC command is a wrapper for grepping for SVC in /var/log/syslog, it makes tons of assumptions about your system. Sorry for that.

firasuke commented 4 years ago

Thank you for taking the time to answer and for your efforts.

I apologize for not providing enough information. I'm working on a linux distribution myself (based on musl libc and toybox), and I'm looking for a lightweight modern init/service supervision suite to use.

So far, I've tested s6 and thought it was the only viable option, but it was until recently that I discovered finit, and I'm liking how simple it is to set it up, without having to worry about bootstrapping or rc.init or any of that.

Regarding this particular issue, it seems that agetty (from util-linux) just won't spawn the login program (which is /bin/login), even if I passed -l /bin/login; It will only work if I used the fallback shell and manually called login as shown below:

Screenshot from 2020-09-14 18-00-23

I've read the documentation, and several other examples/implementations of finit.conf and tried different things to get agetty to work and display a login prompt including (not using all of them at once):

tty [12345] /dev/tty1
tty [12345] agetty tty1
tty [12345] /usr/bin/agetty 38400 /dev/tty1 linux
tty [12345] /usr/bin/agetty -l /usr/bin/login 38400 /dev/tty1 linux

I've also looked at the build.sh and install.sh for both of Alpine and Void, but I still can't seem to figure out why the login program just won't load.

I also have a couple more questions: 1- What's the difference between the fallback shell and the emergency shell? Do I need both of them enabled for debugging purposes? I enabled the emergency shell alone and I wasn't prompted with /bin/sh (which is what the fallback shell would've done), and when I enabled both, the behaviour was similar to having fallback enabled alone.

2- Is finit known to work with musl?

3- Is the output shown when passing debug to the kernel cmdline stored as a file anywhere (the one shown in the image below)?

Screenshot from 2020-09-15 16-15-02

4- Are you aware of the existence of the following project libudev-zero?

5- Would it be possible for you to add support for smdev, or would you say that support for mdev would suffice?

6- Is cgroups support a must for finit to work? What if I had cgroups support disabled in the kernel, will finit still work?

Thanks again!

firasuke commented 4 years ago

Ok, I managed to get this to work.

I noticed after passing debug that the somewhat uncluttered output (thanks to disabling eudev temporarily), showed that finit was attempting to read stuff in /usr/etc instead of /etc (so my finit.conf wasn't being read at all). Apparently passing --prefix=/usr (which is common for many distributions), would cause etc and var to be in /usr/etc and /usr/var instead of /etc and /var.

I actually checked the build.sh files for Alpine and Void and it seems that no --prefix is being used, which explains why there were no such problems.

I ended up configuring finit as follows:

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --sysconfdir=/etc \
    --localstatedir=/var

and using the following /etc/finit.conf:

runlevel 2

tty [12345] agetty 38400 tty1 linux

I don't plan on using /sbin and /usr/sbin, will that cause a problem? Are there any hardcoded paths that require sbin?

winkmichael commented 4 years ago

I don't plan on using /sbin and /usr/sbin, will that cause a problem? Are there any hardcoded paths that require sbin?

From my last go at this from about a year ago, only /sbin/reboot is hardcoded.

firasuke commented 4 years ago

@winkmichael thanks for your response.

I wonder if using --sbindir=/usr/bin would remove the need to patch it (or maybe there's no evading patching it since it's hardcoded)...

winkmichael commented 4 years ago

https://github.com/troglobit/finit/search?q=sbindir&unscoped_q=sbindir If you search for the parameter it looks like it only applies to the building and install

troglobit commented 4 years ago

Interesting project, hope you get it all going! I'll see what I can do about responding to your questions:

  1. The fallback shell is mostly intended for bootstrapping new distros. When enabled in configure it kicks in if no tty is configured. The rescue mode is a special finit.conf (that you can modify for your system), which kicks in if you add rescue to the cmdline
  2. Yes, there is an example for Alpine Linux. If it doesn't work now, then it's a regression and should be reported as a bug
  3. Debug output is sent to syslog, so if you have syslog enabled it goes to whatever you've set up there, otherwise only yo stdout
  4. No. My own systems usually rely on BusyBox, so I'm using mdev, looks interesting though
  5. Had never heard about smdev until now. I have no interest myself, but I'm willing to look at pull requests that integrate it if the changes required aren't too invasive.
  6. It should work without cgroups, it should not be mandatory, I have not tested without it recently so there may be an unintended dependency right now. The master branch is though still under development (despite the lack of activity recently) and not considered release quality.

Regarding the other questions, that @winkmichael helped answer, the configure script has lots of standard levers for controlling paths. Some of which are not (yet) propagated to paths encoded in Finit binaries, that is still on the TODO list and something others are more than welcome to help out with. Hard-coding /sbin is of course not ideal, but I've tried to set up sane defaults based on the FHS, so if you stray from that you're bound to run into problems, unfortunately. (Not just with finit :)

firasuke commented 4 years ago

Thanks for your time and effort, and for your clear answers.

Regarding this issue, maybe adding a small notice in the documentation for building finit to remind the user to double check his final installation paths if he/she decides to use --prefix (which is a pretty common flag that's used in many packages, especially ones that have GNU-like configure scripts) particularly sysconfdir and localstatedir, as they'll become nested under prefix (which will be set to /usr in most cases) and will cause mostly undesirable paths (/usr/etc and /usr/var).

I'm closing this issue as it appears to be solved, thanks again.

troglobit commented 4 years ago

Good point, will do. Thanks and good luck!