|author||Tim Schlueter <email@example.com>||2018-02-25 16:56:04 -0800|
|committer||Tim Schlueter <firstname.lastname@example.org>||2018-02-25 17:22:39 -0800|
Initramfs script improvements
- Resolve the root device, so it can be specified by UUID, etc. - Exit immediately if the ROOTFSTYPE is set and not bcachefs - Only try to unlock the device 3 times before opening a shell or rebooting (depending on kernel cmdline)
1 files changed, 34 insertions, 5 deletions
diff --git a/initramfs/script b/initramfs/script
index bd64b41..e22ace9 100755
@@ -15,11 +15,40 @@ prereqs)
-# Check if it needs unlocking:
-if bcachefs unlock -c $ROOT >/dev/null 2>&1; then
- echo "Unlocking $ROOT:"
+# Nothing to do if ROOTFSTYPE is set to something other than bcachefs
+if [ -n "$ROOTFSTYPE" -a "$ROOTFSTYPE" != bcachefs ]; then
+ exit 0
+# source for resolve_device() and panic() functions
+# Resolve the root device (e.g. if root is specified by UUID)
- while true; do
- bcachefs unlock $ROOT && break
+# Check if the root device needs unlocking:
+if bcachefs unlock -c $DEV >/dev/null 2>&1; then
+ if [ "$DEV" == "$ROOT" ]; then
+ echo "Please unlock $DEV:"
+ echo "Please unlock $DEV ($ROOT):"
+ while [ $tries -le 0 -o $count -lt $tries ]; do
+ if bcachefs unlock "$DEV"; then
+ echo "Bcachefs: $DEV successfully unlocked"
+ let count++
+ if [ $tries -gt 0 -a $count -ge $tries ]; then
+ panic "Bcachefs: maximum number of tries exceeded for $DEV"
+ exit 1