From cbac185434b6fa19e50d6a6aa8596216c310d76c Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sat, 4 Feb 2017 20:09:08 -0700 Subject: init:Additional breakpoints for easier debugging Added a sleep 2 before attempting to access the specified root device to allow for device settling (usb devices sometimes weren't ready yet and causes init to fail). This needs to be replaced later by a 'wait_for_dev' function. Added breakpoint to allow debugging for when the specified root device does not exist. Added a breakpoint for an init script not being detected in the destination root fs. Added breakpoint for failed switch_root. Added many more log messages. --- init | 31 +++++++++++++++++++++++++------ 1 file 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 ${@} -- cgit v1.2.3