summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit63
1 files changed, 22 insertions, 41 deletions
diff --git a/init b/init
index 36dde80..7babfd2 100755
--- a/init
+++ b/init
@@ -121,7 +121,7 @@ parse_cmdline() {
#
setup_encrypted() {
local path="${1}"
- local name="$(echo ${path} | tr / _)"
+ local name="${path//\//_}"
# Decrypted block dev path is /dev/mapper/${name}
cryptsetup luksOpen ${path} ${name}
@@ -144,35 +144,18 @@ setup_encrypted() {
}
-#
-# Waits up to a threshold (in seconds) for the specified path to appear as a
-# block device. A check for device presence occurs once per second.
-#
-# If the device appears within the threshold time, the function returns early
-# with error code 0 (all is well - no need to wait more).
-#
-# If the block device fails to appear within the threshold time, the function
-# returns code 2 (not found)
-#
-# @param dev Path to the device to wait for
-# @param timeout Maximum time (in seconds) to wait for the device to appear
-#
-wait_dev() {
- local dev=${1}
- local timeout=${2}
-
- local wait=0
-
- while [ ${wait} -lt ${timeout} ]; do
- # If the path exists as a block device, exit the wait loop
- [ -b "${dev}" ] && return 0
- # Increment the wait counter
- wait=$(( wait + 1 ))
- # Wait another second for the device to appear
- sleep 1
- done
+udev_populate() {
+ # Start udevd if not already running
+ pidof -s udevd > /dev/null || /sbin/udevd --daemon
- return 2
+ /sbin/udevadm trigger --type=subsystems --action=add
+ /sbin/udevadm trigger --type=devices --action=add --subsystem-match=block
+ /sbin/udevadm trigger --type=devices --action=add --subsystem-match=input
+ /sbin/udevadm settle
+
+ # Shut down udevd once devices are populated so main init can handle udevd to
+ # finish booting
+ kill $(pidof udevd)
}
@@ -182,30 +165,27 @@ wait_dev() {
#
main() {
# Mount the /proc and /sys filesystems.
- mount -t tmpfs none /run
- mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
- mount -t proc -o nodev,noexec,nosuid proc /proc
- mount -t devtmpfs none /dev
- mount -t devpts devpts /dev/pts
- mount -t tmpfs shm /dev/shm
+ mount -t tmpfs -o mode=0755,nousid,nodev none /run
+ mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
+ mount -t proc -o nodev,noexec,nosuid proc /proc
+ mount -t tmpfs shm /dev/shm
+ mount -t devtmpfs -o exec,nosuid,noatime dev /dev
+ mount -t devpts devpts /dev/pts
local fakeroot='/mnt/root'
if [ ! -d "${fakeroot}" ]; then
- log INFO "Fake root location ${fakeroot} does not exist. Creating."
- mkdir ${fakeroot}
+ log INFO "Fake root location ${fakeroot} does not exist. Cannot boot."
fi
parse_cmdline "$(cat /proc/cmdline)"
# display fanciful boot image
screen_init
+ udev_populate
log INFO "Root device: ${ROOTDEV}"
- log INFO "Waiting up to 10 seconds for root device to appear."
- wait_dev "${ROOTDEV}" 10
-
# Drop to maintenance shell if root device does not exist.
if [ "$?" -ne 0 ]; then
log ERROR "ERROR: Root device ${ROOTDEV} does not exist or can not be accessed."
@@ -215,7 +195,8 @@ main() {
fi
# Modprobe atkbd to ensure user can type password
- for i in dm-crypt i8042 atkbd; do
+ # dm-crypt
+ for i in i8042 atkbd; do
printf 'Loading required module [%s]\n' "${i}"
modprobe "${i}" || printf 'Failed loading %s\n' "${i}"
done

Generated by cgit