Does sysfs procfs devtmpfs mounted by kernel?

2019-09-10 04:01发布

问题:

I'm looking into systemd.

I thought systemd would mount sysfs(/sys), procfs(/proc), devtmpfs(/dev) during booting after kernel initialization.

But my systemd debugging log show that systemd doesn't mount such file systems.(it only mounts cgroups, securityfs, etc...)

By when, and whom does such file system is mounted? Does kernel mount sys, proc, dev?

回答1:

Yes, those are mounted by systemd PID1, see src/core/mount-setup.c in the systemd sources.



回答2:

First point: the Linux kernel can't mount pseudo-filesystems at user-level. That's also the reason why, for example, all entries in dev/ must be created by a user-level counterpart (which does not happens for proc/ and sys/ where the kernel is capable of creating the entries on the mounted filesystem).

In Linux distributions the mounting of pseudo-filesystems is typically done at user-level by udev. Of course, the kernel must have been configured for supporting these filesystems (otherwise, mounting won't be possible).