source: bootscripts/lfs/init.d/mountvirtfs@ 44674e4c

12.0 12.0-rc1 12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 44674e4c was 44674e4c, checked in by Xi Ruoyao <xry111@…>, 11 months ago

sysv: Mount cgroup fs for memory pressure information early

Prepare for systemd-254 update. See #5293 for details.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[1c48007]1#!/bin/sh
2########################################################################
[0cda898]3# Begin mountvirtfs
[1c48007]4#
[dda039b]5# Description : Ensure proc, sysfs, run, and dev are mounted
[1c48007]6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
[f874424]8# DJ Lucas - dj@linuxfromscratch.org
[0cda898]9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
[8435a70]10# Xi Ruoyao - xry111@xry111.site
[1c48007]11#
[8435a70]12# Version : LFS 12.0
[1c48007]13#
14########################################################################
15
[0cda898]16### BEGIN INIT INFO
17# Provides: mountvirtfs
[6903d5e]18# Required-Start: $first
[0cda898]19# Should-Start:
20# Required-Stop:
21# Should-Stop:
22# Default-Start: S
23# Default-Stop:
[dda039b]24# Short-Description: Mounts various special fs needed at start
[0cda898]25# Description: Mounts /sys and /proc virtual (kernel) filesystems.
[1025b2a]26# Mounts /run (tmpfs) and /dev (devtmpfs).
[dda039b]27# This is done only if they are not already mounted.
28# with the kernel config proposed in the book, dev
29# should be automatically mounted by the kernel.
[0cda898]30# X-LFS-Provided-By: LFS
31### END INIT INFO
32
[f874424]33. /lib/lsb/init-functions
[1c48007]34
35case "${1}" in
[0cda898]36 start)
[cba2d4e]37 # Make sure /run is available before logging any messages
[c433b2f]38 if ! mountpoint /run >/dev/null; then
[28c4c1e]39 mount /run || failed=1
[7b08ae24]40 fi
41
[16cd0963]42 mkdir -p /run/lock
43 chmod 1777 /run/lock
[0cda898]44
[a44ae577]45 log_info_msg "Mounting virtual file systems: ${INFO}/run"
[0cda898]46
47 if ! mountpoint /proc >/dev/null; then
[9813d5e3]48 log_info_msg2 " ${INFO}/proc"
[28c4c1e]49 mount -o nosuid,noexec,nodev /proc || failed=1
[0cda898]50 fi
51
52 if ! mountpoint /sys >/dev/null; then
[a44ae577]53 log_info_msg2 " ${INFO}/sys"
[28c4c1e]54 mount -o nosuid,noexec,nodev /sys || failed=1
[0cda898]55 fi
56
[e9ba8aa8]57 if ! mountpoint /dev >/dev/null; then
[a44ae577]58 log_info_msg2 " ${INFO}/dev"
[28c4c1e]59 mount -o mode=0755,nosuid /dev || failed=1
[e9ba8aa8]60 fi
61
[16cd0963]62 mkdir -p /dev/shm
63 log_info_msg2 " ${INFO}/dev/shm"
64 mount -o nosuid,nodev /dev/shm || failed=1
[a44ae577]65
[44674e4c]66 mkdir -p /sys/fs/cgroup
67 log_info_msg2 " ${INFO}/sys/fs/cgroup"
68 mount -o nosuid,noexec,nodev /sys/fs/cgroup || failed=1
69
[8435a70]70 (exit ${failed})
71 evaluate_retval
72 if [ "${failed}" = 1 ]; then
73 exit 1
74 fi
75
76 log_info_msg "Create symlinks in /dev targeting /proc: ${INFO}/dev/stdin"
77 ln -sf /proc/self/fd/0 /dev/stdin || failed=1
78
79 log_info_msg2 " ${INFO}/dev/stdout"
80 ln -sf /proc/self/fd/1 /dev/stdout || failed=1
81
82 log_info_msg2 " ${INFO}/dev/stderr"
83 ln -sf /proc/self/fd/2 /dev/stderr || failed=1
84
85 log_info_msg2 " ${INFO}/dev/fd"
86 ln -sf /proc/self/fd /dev/fd || failed=1
87
88 if [ -e /proc/kcore ]; then
89 log_info_msg2 " ${INFO}/dev/core"
90 ln -sf /proc/kcore /dev/core || failed=1
91 fi
92
[0cda898]93 (exit ${failed})
94 evaluate_retval
[f874424]95 exit $failed
[0cda898]96 ;;
97
98 *)
99 echo "Usage: ${0} {start}"
100 exit 1
101 ;;
[1c48007]102esac
103
[f874424]104# End mountvirtfs
Note: See TracBrowser for help on using the repository browser.