diff --git a/install-stage1.sh b/install-stage1.sh index 4978dc0..b7af702 100644 --- a/install-stage1.sh +++ b/install-stage1.sh @@ -102,6 +102,27 @@ else exit 1 fi +if grep "$TARGET_DISK" /proc/mounts >> $LOGFILE 2>&1; then + echo "The device seems to be mounted. Unmount?" + if yesno; then + echo -n "Attempting to unmount... " + readarray -t MOUNTPOINTS <<< "$(findmnt --raw --noheadings --output SOURCE,TARGET | grep "$TARGET_DISK" | sed 's/^[^ ]* //')" + for I in ${!MOUNTPOINTS[@]}; do + umount -R "${MOUNTPOINTS[$I]}" >> $LOGFILE 2>&1 + done + if grep "$TARGET_DISK" /proc/mounts >> $LOGFILE 2>&1; then + echo "failed" + echo "It seems the device is still mounted. Installation cannot continue." + exit 1 + else + echo "done" + fi + else + echo "Aborting." + exit 1 + fi +fi + echo -n "Wiping and partitioning storage... " # new GPT # 2M BIOS GRUB