00-pseudofs.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # shellcheck shell=sh
  2. __mnt() {
  3. for last in "${@}"; do :; done
  4. mountpoint -q "${last}" || mount "${@}"
  5. }
  6. (
  7. umask 0022
  8. cd /dev && \
  9. mkdir pts shm
  10. cd /run && {
  11. mkdir runit
  12. mkdir -m0700 cryptsetup
  13. }
  14. )
  15. msg 'mounting pseudo file systems'
  16. __mnt -o nosuid,noexec,nodev -t proc none /proc
  17. __mnt -o nosuid,noexec,nodev -t sysfs none /sys
  18. __mnt -o mode=0755,nosuid -t devtmpfs none /dev
  19. __mnt -o mode=0755,nosuid,nodev,size=512M -t tmpfs none /run
  20. __mnt -o mode=0620,gid=5,nosuid,noexec -n -t devpts devpts /dev/pts
  21. __mnt -o mode=1777,nosuid,nodev,size=1G -n -t tmpfs shm /dev/shm
  22. __mnt -o mode=0755,size=1M -t tmpfs cgroup /sys/fs/cgroup
  23. msg 'mounting cgroups'
  24. while read -r name _ _ e; do
  25. [ "${e}" = 1 ] && {
  26. mkdir -p "/sys/fs/cgroup/${name}" || continue
  27. __mnt -o "${name}" -t cgroup cgroup "/sys/fs/cgroup/${name}"
  28. }
  29. done < /proc/cgroups
  30. mkdir -p /sys/fs/cgroup/unified
  31. __mnt -o nsdelegate -t cgroup2 cgroup2 /sys/fs/cgroup/unified
  32. msg "remounting root '/'"
  33. mount -o remount /
  34. unset __mnt