From 65cbd16eba3103e5d7cefa61da6b4951b3d59a4c Mon Sep 17 00:00:00 2001 From: Zeev Diukman Date: Sun, 18 Jan 2026 08:52:40 +0200 Subject: [PATCH] refactor: adjust device unmounting logic to target specific devices instead of `/mnt`. --- z.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/z.sh b/z.sh index c5fd8ae..02c54ed 100755 --- a/z.sh +++ b/z.sh @@ -112,9 +112,11 @@ else mkfs.fat -F 32 -n EFI "$efi_device" echo "Filesystems created successfully." fi -if mountpoint -q /mnt; then - echo "/mnt is already mounted. Unmounting..." - umount -R /mnt + +# check if any of the devices is mounted +if mountpoint -q "$seed_device" || mountpoint -q "$sprout_device" || mountpoint -q "$efi_device"; then + echo "One or more devices are already mounted. Unmounting..." + umount -R "$seed_device" "$sprout_device" "$efi_device" fi mount -o subvol=/ "$seed_device" /mnt @@ -122,6 +124,7 @@ mount -o subvol=/ "$seed_device" /mnt if btrfs subvolume list /mnt | grep -q "@$"; then btrfs subvolume delete /mnt/@ fi + btrfs su cr /mnt/@ umount -R /mnt mount -o subvol=/@ "$seed_device" /mnt