source: bootscripts/lfs/init.d/mountvirtfs

trunk
Last change on this file was 44674e4c, checked in by Xi Ruoyao <xry111@…>, 9 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
Line 
1#!/bin/sh
2########################################################################
3# Begin mountvirtfs
4#
5# Description : Ensure proc, sysfs, run, and dev are mounted
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8# DJ Lucas - dj@linuxfromscratch.org
9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10# Xi Ruoyao - xry111@xry111.site
11#
12# Version : LFS 12.0
13#
14########################################################################
15
16### BEGIN INIT INFO
17# Provides: mountvirtfs
18# Required-Start: $first
19# Should-Start:
20# Required-Stop:
21# Should-Stop:
22# Default-Start: S
23# Default-Stop:
24# Short-Description: Mounts various special fs needed at start
25# Description: Mounts /sys and /proc virtual (kernel) filesystems.
26# Mounts /run (tmpfs) and /dev (devtmpfs).
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.
30# X-LFS-Provided-By: LFS
31### END INIT INFO
32
33. /lib/lsb/init-functions
34
35case "${1}" in
36 start)
37 # Make sure /run is available before logging any messages
38 if ! mountpoint /run >/dev/null; then
39 mount /run || failed=1
40 fi
41
42 mkdir -p /run/lock
43 chmod 1777 /run/lock
44
45 log_info_msg "Mounting virtual file systems: ${INFO}/run"
46
47 if ! mountpoint /proc >/dev/null; then
48 log_info_msg2 " ${INFO}/proc"
49 mount -o nosuid,noexec,nodev /proc || failed=1
50 fi
51
52 if ! mountpoint /sys >/dev/null; then
53 log_info_msg2 " ${INFO}/sys"
54 mount -o nosuid,noexec,nodev /sys || failed=1
55 fi
56
57 if ! mountpoint /dev >/dev/null; then
58 log_info_msg2 " ${INFO}/dev"
59 mount -o mode=0755,nosuid /dev || failed=1
60 fi
61
62 mkdir -p /dev/shm
63 log_info_msg2 " ${INFO}/dev/shm"
64 mount -o nosuid,nodev /dev/shm || failed=1
65
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
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
93 (exit ${failed})
94 evaluate_retval
95 exit $failed
96 ;;
97
98 *)
99 echo "Usage: ${0} {start}"
100 exit 1
101 ;;
102esac
103
104# End mountvirtfs
Note: See TracBrowser for help on using the repository browser.