Browse Source

Example services: mount /dev/pts and /dev/shm in early-filesystems

Also, don't try and clear /var/lock and /var/run, we should assume they
are symlinks back to /run[/lock] which doesn't survive reboot anyway.
Davin McCall 3 years ago
parent
commit
31f1398121
2 changed files with 15 additions and 10 deletions
  1. 9 4
      doc/linux/services/early-filesystems.sh
  2. 6 6
      doc/linux/services/rcboot.sh

+ 9 - 4
doc/linux/services/early-filesystems.sh

@@ -8,15 +8,20 @@ if [ "$1" = start ]; then
 
     # Must have sysfs mounted for udevtrigger to function.
     mount -n -t sysfs sysfs /sys
-    # Ideally devtmpfs will be mounted by kernel:
+    
+    # Ideally devtmpfs will be mounted by kernel, we can mount here anyway:
     mount -n -t devtmpfs tmpfs /dev
+    mkdir -p /dev/pts /dev/shm
+    mount -n -t tmpfs -o nodev,nosuid tmpfs /dev/shm
+    mount -n -t devpts -o gid=5 devpts /dev/pts
+
+    # /run, and various directories within it
     mount -n -t tmpfs -o mode=775 tmpfs /run
+    mkdir /run/lock /run/udev
+    
     # "hidepid=1" doesn't appear to take effect on first mount of /proc,
     # so we mount it and then remount:
     mount -n -t proc -o hidepid=1 proc /proc
     mount -n -t proc -o remount,hidepid=1 proc /proc
-    mkdir /run/udev
-    mkdir /dev/pts
-    mkdir /dev/shm
 
 fi

+ 6 - 6
doc/linux/services/rcboot.sh

@@ -9,15 +9,15 @@ if [ "$1" != "stop" ]; then
   # cleanup
   # (delete /tmp etc)
   rm -rf /tmp/* /tmp/.[!.]* /tmp/..?*
-  rm -rf /var/lock/* /var/lock/.[!.]* /var/lock/..?*
-  rm -rf /var/run/* /var/run/.[!.]* /var/run/..?*
-  # create state directories
+  
+  # empty utmp, create needed directories
   : > /var/run/utmp
-  mkdir /var/run/dbus
-  chmod og+rx /var/run/dbus
+  mkdir -m og-w /var/run/dbus
 
   # Configure random number generator
-  cat /var/state/random-seed > /dev/urandom
+  if [ -e /var/state/random-seed ]; then
+    cat /var/state/random-seed > /dev/urandom;
+  fi
   
   # Configure network
   /sbin/ifconfig lo 127.0.0.1