install stage 1: Attempt to unmount target disk if it’s mounted

master
BodgeMaster 2023-06-30 13:22:20 +02:00
parent 49e67ac001
commit d7629049d6
1 changed files with 21 additions and 0 deletions

View File

@ -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