Re: [systemd-devel] About systemd in initrd support

2014-08-25 Thread Lennart Poettering
On Sat, 23.08.14 13:46, Luca Bruno (lethalma...@gmail.com) wrote:

 I'm going to do an experiment with NixOS: replace the whole current initrd
 process made of scripts and hooks with systemd.
 
 Before doing any work however I'd like to hear whether systemd in initrd is
 still wanted in the future, or there's any possible idea about dropping
 this support.

Of course, this is absolutely somethign we support. In fact, this is how
Fedora and suchlike boot since quite some time, and Dracut supports it
out-of-the-box.

 Also, apart arch linux, is there any other OS that you know using systemd
 for the whole initrd process?

Everything Dracut-based, including Fedora, RHEL7 and similar.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-25 Thread Luca Bruno
Thank you all for the replies. After the first answers I've ported the
initrd to systemd (only the basic stuff, no luks, lvm, etc.) and works very
fine.
Except one thing, that I hoped to find in dracut but does not seem to do
anything special about it. It just goes through switch-root it seems.

As I understood it, systemctl switch-root will either run the specified
init, or exec to the systemd in the new root. Looking a little through the
code, it seems to do some kind of state-passing that I still have to study
(--switched-root --deserialize etc.).

Problem: in NixOS we need to run a further stage in the new root, before
starting systemd. For example /etc is a symlink to a configuration tree
which gets created at boot (we call it activation), and so on.
Our init script activates the NixOS system and ultimately exec to systemd.

initrd init - setup some env vars and mount points - systemd/initrd -
switch-root - system activation script - systemd.

Questions:
1) What are the advantages to let switch-root exec to systemd directly?
Does executing it from our init is the same thing?
2) In case it's not the same thing, where is the best place to run that
script? As a service in the new-root systemd?

Thanks.

Best regards,
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-25 Thread Luca Bruno


 As you already mentioned, you'd have to make sure you manage to pass
 through the state correctly.


Thanks. Is there any docs I can read about this or just read the code? It
appears that systemd dumps the state into a file, and afterwards it's
passed to the new systemd instance.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-25 Thread Lennart Poettering
On Mon, 25.08.14 21:04, Luca Bruno (lethalma...@gmail.com) wrote:

 Thank you all for the replies. After the first answers I've ported the
 initrd to systemd (only the basic stuff, no luks, lvm, etc.) and works very
 fine.
 Except one thing, that I hoped to find in dracut but does not seem to do
 anything special about it. It just goes through switch-root it seems.
 
 As I understood it, systemctl switch-root will either run the specified
 init, or exec to the systemd in the new root. Looking a little through the
 code, it seems to do some kind of state-passing that I still have to study
 (--switched-root --deserialize etc.).

Yes, we serialize the state of all units into a file, and pass its fd
plus all other open fds we need need to pass over via the exec(). On the
other side we deserialize the stream, and try to match the passed fds to
what the serialization says. But this is mostly internal, the file is
never visible in the filesystem (it is deleted right after creation),
nobody should interfere with that.

 Problem: in NixOS we need to run a further stage in the new root, before
 starting systemd. For example /etc is a symlink to a configuration tree
 which gets created at boot (we call it activation), and so on.
 Our init script activates the NixOS system and ultimately exec to
 systemd.

I'd recommend doing that in an initrd service, that you run after
/sysroot is mounted, and before we actually switch roots.

The serialization is only enabled if we detect that the binary we invoke
is actually systemd. Because otherwise the invoked process could get
seriously confused by the open fds we dump on it...

 initrd init - setup some env vars and mount points - systemd/initrd -
 switch-root - system activation script - systemd.
 
 Questions:
 1) What are the advantages to let switch-root exec to systemd directly?
 Does executing it from our init is the same thing?

Well, you get the state serialization and stuff, which means after
boot-up you can investigate what happened to the initrd services and
stuff... Also, you get fancy stuff like that we switch-root back into
the initrd, so that the initrd can unmount the root file system before
going down.

 2) In case it's not the same thing, where is the best place to run that
 script? As a service in the new-root systemd?

As a service in the initrd.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-25 Thread Lennart Poettering
On Mon, 25.08.14 22:13, Luca Bruno (lethalma...@gmail.com) wrote:

  As you already mentioned, you'd have to make sure you manage to pass
  through the state correctly.
 
 
 Thanks. Is there any docs I can read about this or just read the code? It
 appears that systemd dumps the state into a file, and afterwards it's
 passed to the new systemd instance.

No, it's not documented, it's an internal interface of systemd. Nobody
should interfere with it...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] About systemd in initrd support

2014-08-23 Thread Luca Bruno
I'm going to do an experiment with NixOS: replace the whole current initrd
process made of scripts and hooks with systemd.

Before doing any work however I'd like to hear whether systemd in initrd is
still wanted in the future, or there's any possible idea about dropping
this support.

Also, apart arch linux, is there any other OS that you know using systemd
for the whole initrd process?

Thanks for you work.

Best regards,

-- 
www.debian.org - The Universal Operating System
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-23 Thread Simon Peeters
Hej,

2014-08-23 13:46 GMT+02:00 Luca Bruno lethalma...@gmail.com:
 I'm going to do an experiment with NixOS: replace the whole current initrd
 process made of scripts and hooks with systemd.

 Before doing any work however I'd like to hear whether systemd in initrd is
 still wanted in the future, or there's any possible idea about dropping this
 support.

I think this is definitly still wanted.

 Also, apart arch linux, is there any other OS that you know using systemd
 for the whole initrd process?

Every distribution that uses dracut as an initramfs, including mageia,
fedora and RHEL.

 Thanks for you work.

 Best regards,




Simon Peeters
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-23 Thread Tobias Geerinckx-Rice
On 23 August 2014 13:46, Luca Bruno lethalma...@gmail.com wrote:
 I'm going to do an experiment with NixOS: replace the whole current initrd
 process made of scripts and hooks with systemd.

What a coincidence... I just switched to NixOS last week, moved some
file systems around, and promptly broke my boot. Badly.

The learning curve was steepened by the proprietary initrd script,
which gave me exactly 0 error messages until I could find a live CD
and look up the NixOS-specific boot options on-line. It also manages
to boot slower than my previous systemd-based initrds.

So, yes -- please.

 Also, apart arch linux, is there any other OS that you know using systemd
 for the whole initrd process?

Simon's right: switching to dracut brings relatively decent systemd
support more or less for free. I'd focus on that.

Regarding distributions: I've been using dracut on Exherbo (A Less
Brain-dead Gentoo®) for a year or so. It's the official initrd
generator in that there's a blog post somewhere saying guys you
really should use dracut, but there's no distribution-specific code
or glue anywhere. It still works flawlessly. I take that as a
heartening hint that using it under NixOS should be relatively
straightforward.

Regards,

T G-R

 Thanks for you work.

 Best regards,

 --
 www.debian.org - The Universal Operating System

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel