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:



# Do the backup


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?


Referring to a drive by /dev/sdX letter is unreliable, in my experience. Instead, find the device's uuid:

joe@computer:~$ lsblk -o +UUID
NAME                  MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT                     UUID
sda                     8:0    0 119.2G  0 disk                                
└─sda1                  8:1    0 119.2G  0 part                 XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXXXX
  ├─ubuntu--vg-root   253:0    0 118.3G  0 lvm  /               XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXXXX
  └─ubuntu--vg-swap_1 253:1    0   976M  0 lvm  [SWAP]          XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXXXX
sdb                     8:16   0 698.7G  0 disk                                
├─sdb1                  8:17   0   100M  0 part                 XXXXXXXXXXXXXXXX
└─sdb2                  8:18   0 698.6G  0 part /media/XXXX     USBPARTITIONUUID

Then in your script replace




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.