Auto Mounting External USB drives

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: AZ Pete via PLUG-discuss
Date:  
To: PLUG Discuss
CC: AZ Pete
Subject: Auto Mounting External USB drives
Hi all,

I was finally able to do away with an aging Windows machine and replace it with a Raspberry Pi 4 running Buster.  The only purpose for this server is to backup selected folders and files from other servers onto two external USB drives for offsite storage. I've automated the backup process using rsync and a cron job. All is working well and the backups are happening on schedule.
However, currently I have to manually mount each of the external drives. This isn't a terribly big issue since the drives are rotated to offsite storage only once per month. But, if the Pi gets rebooted, the drives are not being auto-mounted and the backups will then fail. I've tried putting an entry in /etc/fstab to auto-mount them at boot, but if they drives are not connected at boot time, I've found the the Pi doesn't boot (it just seems to hang).

Here is how I mount the drives.
mount -t ntfs PARTUUID=c6040663-9321-4d28-91f0-2f3eb35f72b7 /mnt/Ext3TB_Data1/
mount -t ntfs PARTUUID=f88c9c86-e44d-4846-9fbe-305074347e97 /mnt/Ext3TB_Video1/

How can I "conditionally" mount an external drive based on if the drive is currently connected? I could write a script that checks if the particular partition (PARTUUID) is currently connected but not mounted and put this script in the rc.local folder to be executed at boot.
Is this the best way? I'm sure that others have encountered this issue and wanted to know what the "best practices" are on how to achieve this?

Any thoughts would be appreciated.

Thanks,
Peter




---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss