From d7629049d66a5f61b089047969a67a4b082a0031 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Fri, 30 Jun 2023 13:22:20 +0200 Subject: [PATCH] =?UTF-8?q?install=20stage=201:=20Attempt=20to=20unmount?= =?UTF-8?q?=20target=20disk=20if=20it=E2=80=99s=20mounted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-stage1.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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