Who mounts /proc and /sys in GNU/Linux systems?

If you build a custom GNU/Linux system for an embedded device, do you need to execute

mount -t proc proc /proc
mount -t sysfs sysfs /sys

somewhere in init process or is this done automatically by the kernel? I’ve read contradicting statements about this. An embedded Linux book advises to run the commands in init scripts while I’ve read somewhere that Systemd is not doing this as it is done by the kernel before userspace is created.

What is actually true? Who mounts /proc and /sys?

Asked By: mrn

||

If you have systemd, it does that automatically (and some extra mount points as well, including /dev/, /dev/shm, /dev/pts, /run and even /tmp).

If you have a different init system, you’ll have to do that according to its documentation, most likely manually using /etc/fstab or/and scripts.

Here’s what gets mounted on Fedora 38 with systemd automatically without any configuration files:

debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
devtmpfs on /dev type devtmpfs (rw,nosuid,noexec,relatime,seclabel,size=32889888k,nr_inodes=8222472,mode=755)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime,seclabel)
ramfs on /run/credentials/systemd-sysctl.service type ramfs (ro,nosuid,nodev,noexec,relatime,seclabel,mode=700)
ramfs on /run/credentials/systemd-tmpfiles-setup-dev.service type ramfs (ro,nosuid,nodev,noexec,relatime,seclabel,mode=700)
ramfs on /run/credentials/systemd-tmpfiles-setup.service type ramfs (ro,nosuid,nodev,noexec,relatime,seclabel,mode=700)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,nosuid,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,size=13156600k,nr_inodes=819200,mode=755)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=6578296k,nr_inodes=1644574,mode=700,uid=1000,gid=1000)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=49337248k)
tmpfs on /var/tmp type tmpfs (rw,nosuid,nodev,relatime,seclabel)
Answered By: Artem S. Tashkinov
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.