Hello. I’m a new DietPi user with a headless RPi4 trying to replicate functionality I had on a now-defunct TonidoPlug device.
The main use of this device is to use rsync to copy remote files to an external USB drive connected to the Pi for backup purposes. I have two identical USB drives that I regularly swap out, keeping one attached to the device while storing the other offsite. The drives of course do not contain the boot partition.
In my previous TonidoPlug setup, both drives mounted to the same location, so I could use the same rsync command in a script. I don’t have a copy of that fstab file for reference, so as a first shot, I tried using dietpi-drive_manager to mount the two drives, and then editing the fstab lines to make them use the same mountpoint. Didn’t work. I also know that dietpi-drive_manager will overwrite this file if I run it again for any reason.
Here are my current /etc/fstab entries with each drive getting a unique mountpoint.
UUID=A0F65096F6506F12 /mnt/WD6TB_1 ntfs noatime,lazytime,rw,permissions,big_writes,nofail,noauto,x-systemd.automount
UUID=AE8C7B328C7AF465 /mnt/WD6TB_2 ntfs noatime,lazytime,rw,permissions,big_writes,nofail,noauto,x-systemd.automount
This seems to be ok as far as plugging in either drive and accessing it. It would be fine (maybe even better than the same mountpoint for each), except for two issues…
- I don’t know how to identify in a bash script for my rsync command which drive is currently connected. I found the following suggestion on a different forum, but both entries are in /proc/mounts, so it shows them both as mounted even when one isn’t connected.
grep -q ’ /mnt/WD6TB_1 ’ /proc/mounts && echo “mounted” || echo “not mounted”
- I know (or think) that x-systemd sort of mounts the device on the fly when it is first accessed. But when I try to cd into the directory of the drive that isn’t mounted, the shell locks up.
Can anyone offer some advice on how to either at least solve issue 1 (identify in a script which drive is connected)? Or help me figure out how to make it so both drives have the same mountpoint? I hope I’ve described things well enough, but let me know if I haven’t
Thanks in advance. I really appreciate it!