I have this code:
echo "Mount External Backup @ $externalBackupDrivePath"
for uuid in /dev/disk/by-uuid/*;
do
if [[ "$uuid" =~ $externalBackupDriveID ]]; then
if [[ $(mount | grep "$(readlink -e "$uuid")") ]]; then
echo "External BackUp Drive is mounted"; echo; else sudo mount UUID=$externalBackupDriveID $externalBackupDrivePath
echo "External BackUp Drive is mounted"; echo
fi
fi
done
It is meant to look for my external drive, and mount it for use as a backUp drive in a script.
It works if the drive is on, but gives worrying result if it’s off. Would like to clean it up so I get a better result or a warning that the drive cannot be located.
The result I’m getting is:
[sudo] password for me:
mount: UUID=: can’t find in /etc/fstab.
External BackUp Drive is mounted
External BackUp Drive is mounted
mount: UUID=: can’t find in /etc/fstab.
External BackUp Drive is mounted
External BackUp Drive is mounted
External BackUp Drive is mounted
External BackUp Drive is mounted
That output is erroneous, drive is NOT mounted or even powered on.
Would like my script to pick up on the fact that the drive isn’t connected.
I’ve tried a bunch of things to no avail………………….