开发者

Graceful handing over resources from initramfs to userspace

There are hardware devices which need userspace suppport, like daemon running and handling parts of interaction not suitable (too complex or policy-related) for kernel space.

Running such daemons is easy once you reach userspace -- you can run'em as a result of hotplug event and don't worry much.

Once initramfs comes to the picture, everything suddenly breaks apart: if the daemon is run from initramfs then it needs to either keep running when execu开发者_运维问答tion is switched to regular rootfs, which is particularily hard, given initramfs is freed during switch_root or hand out resources and state to another copy of itself, run from rootfs. Both solutions seem inelegant and hacky.

Is there obvious way to manage such devices and their supporting daemons I overlooked?


Do you have a specific case? How have the other distributions handled this?

Looking at how Fedora does udev, it starts it up from the initramfs, gets it to do its stuff so the really root fs can be mounted, then shuts it down again before switching.


Do you need this daemon to mount your real root device ? I guess the answer is yes, otherwise the solution would be to wait for your real root.

I your device is so complicated it needs a daemon to just work, may be you could do part of the job in the kernel, and handle the policy through sysfs attribute ? I fail to see an example of hardware invlved in mounting the real root deice that would need a daemon to work. Device discovery apply, but you don't need a daemon for the device to actually work. An example would be welcome.

Also, do you really need to switch root ? You could keep your initramfs, and mount whatever you need to have a fully functionnal system under /usr/ That is what I do with some of my embedded system.

Update : mdev is an embedded alternative to udev, which runsin two mode: on scans sysfs to add device, the other is running for hotplug event. So I guess you don't need to "store" hotplug event, because all the info is still available in sysfs. So the solution is something like :

  • run udev from initramfs
  • mount real root and switch root
  • scan sysfs (does udev do that on startup ?)
  • normal operation (ie wait for hotplug event)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜