[systemd-devel] Fwd: Does Systemd also mount sysfs, procfs?

Lennart Poettering mzerqung at 0pointer.de
Fri Dec 18 03:29:08 PST 2015


On Fri, 18.12.15 09:19, 유준봉 (mountainlion0523 at gmail.com) wrote:

> Hi I just started to understand systemd source code.
> 
> Now I'm curious about mounting linux pseudo-filesystemd like sysfs and
> porcfs.
> 
> In main( ) function from /src/core/main.c, there is several mounting
> related functions like:
> 1. mount_setup_early
> 2. mount_setup
> 3. mount_cgroupt_controllers
> and also, there is table named 'mount_table'
> 
> I used log_info( ) to see which file systems that systemd mounts. But none
> of them was sysfs or procfs(systemd only mounts: securityfs, tmpfs, devfs,
> etc. but not sysfs and procfs).
> 
> I also tracked why systemd does not mount sysfs and procs.
> Inside mount_one( ) function, systemd uses name_to_handle_at( ) to get
> mount_id.
> 
> For sysfs('/sys'), or procfs('/proc'), name_to_handle_at( ) returns
> fail(EOPNOTSUPP). But for its parent('/'), name_to_handle_at( ) returns
> success. and in this case, systemd doesn't mount such file systems.
> 
> Now, this is my question:
> What this situation means when child directory returns fail for
> name_to_handle_at( ) but its parent returns success for the same function?
> does it mean '/sys' is already mounted before '/sbin/init' is executed? If
> so, then who mounts sysfs, procfs, and also rootfs?(script? other initial
> process?)

When an initrd is in use systemd will inherit mounts from it, and that
usually includes /proc and /sys.

And even without an initrd, the kernel usually passes /dev pre-mounted
to userspace, too.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list