summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2017-02-04 20:12:41 -0700
committerAaron Ball <nullspoon@oper.io>2017-02-04 20:12:41 -0700
commitc7814a04421e5aaad186778f3cfc122b6bad252a (patch)
tree1f219cdb443fba4b2e7ae334bad7d6aa452c279a
parent422145765b0eea6ccde695c4d82a18370e02c712 (diff)
parentcbac185434b6fa19e50d6a6aa8596216c310d76c (diff)
downloadmkinitramfs-c7814a04421e5aaad186778f3cfc122b6bad252a.tar.gz
mkinitramfs-c7814a04421e5aaad186778f3cfc122b6bad252a.tar.xz
Merge branch 'init-breakpoints'
-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