I have a Linux (Pop OS 18.1) laptop connected to an external monitor that I use as a docking station. A USB drive is plugged into one of the monitor's USB ports.
I want to use the USB drive for backup purposes. To that end, there is a cron job that runs daily and does the following:
BACKUP_DEVICE=/dev/sda1 umount $BACKUP_DEVICE pmount -A $BACKUP_DEVICE # Do the backup umount $BACKUP_DEVICE
I want the USB drive to be mounted only during the backup. This allows me to unplug the monitor (and hence the drive) safely. To be safe, the backup starts by calling umount to ensure the drive is unmounted, and then mounts it, does the backup, and unmounts again.
The problem is that umount and pmount sometimes go wrong:
umount: /dev/sda1: no mount point specified. Error: device /dev/sda1 does not exist
1) I don't know how to explain the umount error message. If the USB drive is not mounted and I manually umount, the error message is slightly different: ""umount: /dev/sda1: not mounted." So I don't know what causes the above umount error message.
2) /dev/sda1 doesn't exist?! It's plugged in, and when unmounted, is still listed in /dev.
I seem to be barking up the wrong tree. What is the right way to ensure that a USB drive is mounted only for the duration of my backup script?