[arch-projects] [PATCH] init_functions: rework `default_mount_handler` -- assume less/succeed more
C Anthony Risinger
anthony at xtfx.me
Thu Nov 17 01:20:54 EST 2011
mostly shuffling, save:
1) immediate mount attempt: assume hooks have allowed for this
$root is opaque, attempts to dechiper it's meaning are out of scope.
2) first mount fail: print details, offer to mount(0) or boot(1)
3) second mount fail: print details, offer to reboot(0) or boot(1)
this work allows the default handler to be used in nearly all cases mount
itself could handle -- work prompted by needless failing of a virtio/9p2000.L
based passthru "device" as $root.
Signed-off-by: C Anthony Risinger <anthony at xtfx.me>
---
init_functions | 37 ++++++++++++++++++++++++++-----------
1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/init_functions b/init_functions
index 42e6249..d0bd042 100644
--- a/init_functions
+++ b/init_functions
@@ -197,18 +197,33 @@ resolve_device() {
}
default_mount_handler() {
- if [ ! -b "$root" ]; then
- err "Unable to determine major/minor number of root device '$root'."
- echo "You are being dropped to a recovery shell"
- echo " Type 'exit' to try and continue booting"
- launch_interactive_shell
- msg "Trying to continue (this will most likely fail) ..."
- fi
+ local opts="${rootfstype:+-t $rootfstype} -o ${rwopt:-ro}${rootflags:+,$rootflags}"
- if ! mount ${fstype:+-t $fstype} -o ${rwopt:-ro}${rootflags:+,$rootflags} "$root" "$1"; then
- echo "You are now being dropped into an emergency shell."
- launch_interactive_shell
- msg "Trying to continue (this will most likely fail) ..."
+ if ! mount ${opts} "$root" "$1"; then
+ if [ ! -b "$root" ]; then
+ err "Unable to determine major/minor number of root device '$root'."
+ fi
+ echo $'\n'"Unable to mount root device '$root'! (1 of 2)"$'\n'
+ echo "mount ${opts} '$root' '$1'"$'\n'
+ echo "You are being dropped to an recovery shell, typing ..."
+ echo " 'exit 0' attempts to boot after first retrying the failed mount."
+ echo " 'exit 1' attempts to boot immediately -- '$1' MUST be mounted."
+ if launch_interactive_shell; then
+ echo "Attempting to mount '$root' ..."
+ if ! mount ${opts} "$root" "$1"; then
+ echo $'\n'"Unable to mount root device '$root'! (2 of 2)"$'\n'
+ echo "mount ${opts} '$root' '$1'"$'\n'
+ echo "You are being dropped to an emergency shell, typing ..."
+ echo " 'exit 0' abruptly ends our adventure and reboots the machine."
+ echo " 'exit 1' attempts to boot immediately -- '$1' MUST be mounted."
+ if launch_interactive_shell; then
+ echo $'\n'":: Boot aborted, reboot in progress"
+ sleep 2
+ reboot -f
+ fi
+ fi
+ fi
+ echo "Trying to continue (will fail unless '$root' is mounted) ..."
fi
}
--
1.7.7.3
More information about the arch-projects
mailing list