summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit31
1 files changed, 25 insertions, 6 deletions
diff --git a/init b/init
index 8168485..b0e2828 100755
--- a/init
+++ b/init
@@ -140,6 +140,17 @@ function main {
log "Root device: ${ROOTDEV}"
+ log "Waiting a few seconds for devices to settle."
+ sleep 2
+
+ # Drop to maintenance shell if root device does not exist.
+ if [[ ! -b ${ROOTDEV} ]]; then
+ log "ERROR: Root device ${ROOTDEV} does not exist or can not be accessed."
+ log " Dropping to maintenance shell for troubleshooting."
+ log " (You may just need to wait longer for the root device)"
+ /bin/bash -i
+ fi
+
if [[ $(get_part_type ${ROOTDEV}) == 'luks' ]]; then
# Set new rootdev location (/dev/mapper/something). This will update it to
# the decrypted block device path.
@@ -153,18 +164,26 @@ function main {
log "Interractive shell requested. Type 'exit' to continue boot sequence."
/bin/bash --norc
fi
-
+
# Mount the fakeroot.
log "Mounting fakeroot"
mount_fakeroot ${ROOTDEV} ${fakeroot}
+ # Ensure switch_root will be possible for destination fakeroot
+ if [[ ! -f ${fakeroot}/sbin/init ]]; then
+ log "ERROR: Destination fakeroot ${fakeroot} does not have an init script."
+ log " Cannot proceed. Dropping to shell for troubleshooting."
+ /bin/bash -i
+ fi
+
# Boot the real McCoy
+ log "Switching root"
exec switch_root ${fakeroot} /sbin/init
- if [[ $? -gt 0 ]]; then
- log "There was an error performing switch_root to ${fakeroot}."
- log "Starting recovery shell."
- /bin/bash
- fi
+
+ # This will be reached if previous command failed
+ log "There was an error performing switch_root to ${fakeroot}."
+ log "Starting recovery shell."
+ /bin/bash -i
}
main ${@}

Generated by cgit