mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-24 00:00:19 +03:00
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)
This commit is contained in:
parent
cdf17bffad
commit
c3b8d74200
@ -15,11 +15,40 @@ prereqs)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Check if it needs unlocking:
|
# Nothing to do if ROOTFSTYPE is set to something other than bcachefs
|
||||||
if bcachefs unlock -c $ROOT >/dev/null 2>&1; then
|
if [ -n "$ROOTFSTYPE" -a "$ROOTFSTYPE" != bcachefs ]; then
|
||||||
echo "Unlocking $ROOT:"
|
exit 0
|
||||||
|
|
||||||
while true; do
|
|
||||||
bcachefs unlock $ROOT && break
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# source for resolve_device() and panic() functions
|
||||||
|
. /scripts/functions
|
||||||
|
|
||||||
|
# Resolve the root device (e.g. if root is specified by UUID)
|
||||||
|
DEV=$(resolve_device "$ROOT")
|
||||||
|
|
||||||
|
# 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:"
|
||||||
|
else
|
||||||
|
echo "Please unlock $DEV ($ROOT):"
|
||||||
|
fi
|
||||||
|
|
||||||
|
count=0
|
||||||
|
tries=3
|
||||||
|
while [ $tries -le 0 -o $count -lt $tries ]; do
|
||||||
|
if bcachefs unlock "$DEV"; then
|
||||||
|
echo "Bcachefs: $DEV successfully unlocked"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
let count++
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $tries -gt 0 -a $count -ge $tries ]; then
|
||||||
|
panic "Bcachefs: maximum number of tries exceeded for $DEV"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user