source: bootscripts/lfs/init.d/mountvirtfs@ 8435a70

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 8435a70 was 8435a70, checked in by Xi Ruoyao <xry111@…>, 11 months ago

bootscripts: mountvirtfs: Create essential symlinks in /dev targeting /proc

These were handled by Eudev, but systemd-udevd stopped to creating them
since 2020.

  • Property mode set to 100644
File size: 2.8 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 (exit ${failed})
67 evaluate_retval
68 if [ "${failed}" = 1 ]; then
69 exit 1
70 fi
71
72 log_info_msg "Create symlinks in /dev targeting /proc: ${INFO}/dev/stdin"
73 ln -sf /proc/self/fd/0 /dev/stdin || failed=1
74
75 log_info_msg2 " ${INFO}/dev/stdout"
76 ln -sf /proc/self/fd/1 /dev/stdout || failed=1
77
78 log_info_msg2 " ${INFO}/dev/stderr"
79 ln -sf /proc/self/fd/2 /dev/stderr || failed=1
80
81 log_info_msg2 " ${INFO}/dev/fd"
82 ln -sf /proc/self/fd /dev/fd || failed=1
83
84 if [ -e /proc/kcore ]; then
85 log_info_msg2 " ${INFO}/dev/core"
86 ln -sf /proc/kcore /dev/core || failed=1
87 fi
88
89 (exit ${failed})
90 evaluate_retval
91 exit $failed
92 ;;
93
94 *)
95 echo "Usage: ${0} {start}"
96 exit 1
97 ;;
98esac
99
100# End mountvirtfs
Note: See TracBrowser for help on using the repository browser.