I am currently working on a bash script which should mount a veracrypt encrypted hdd on sundays to run backups. Since I want to rotate between two different HDDs every week, I have to check whether /dev/sdb1 or /dev/sdc1 is currently connected to the device before it gets mounted by the script:
hdd_sdb1="$(fdisk -l | grep /dev/sdb1)"
hdd_sdc1="$(fdisk -l | grep /dev/sdc1)"
if [ -n "$hdd_sdb1" ]
then
hdd_name=/dev/sdb1
fi
if [ -n "$hdd_sdc1" ]
then
hdd_name=/dev/sdc1
fi
Last weekend I've just changed the variable in the script and the mount worked fine. This weekend, when the script was run, none of the above fdisk commands returned a line, so the if query wasn't working. Now I wonder if the operating system deactivates the hard disk after a while if it has not been mounted and if there is a way to deactivate this?
fdisk
interactively from the command line?fdisk
output so you can see what it sees.