To implement a easy backup system in a PLC-application, we access a USB-Stick attached to an external Ubuntu-system. Therefore, the first attached USB-drive should be shared over Samba as soon as it gets attached.
The first attached USB always gets the path /dev/sdb. This dynamically mounted removable device should now always be shared with a fix name like "USB_DRIVE".
My problem is, that the drive is mounted with it's device description like "KENSINGTON". If the folder /media/KENSINGTON is shared, and the device gets removed and another Drive with the name "SCANDISK" is attached, it will not be shared.
So here are my questions:
- Is there a possibility to share a removable device with its path? So that always path /dev/sdb gets shared as soon as it is connected?
- I tried to bind a folder /mnt/USB_DRIVE to a specific mounted device like /media/KENSIGNTON. But the name of the folder in the media folder is not fixes. Can the name of the dynamically created folder /media/KENSINGTON be changed to the name of the path like /media/sdb'
- Is there another way to share the first attached usb-drive?
I'm aware of the security topics. The samba-shared folder is protected by a username and password.
A user should have the freedom to attach the stick he want to create a backup. So I cannot use the device name but need to determine the first one connected which has the path /dev/sdb/
/etc/fstab is definitely not working because the devices are dynamically plugged.
The best solution would be, if ubuntu would not mount the devices to the folder /media/ (Sample /media/Kensington) but with the path /media/ (Sample /media/sdb) Can it be configured somehow?
The usbmount tool seems to be a solution pointing into this direction. But as soon as it is installed, it generates the folders and they all remain empty, even if an usb-device is attached. What can be done wrong? Is it possible to configure the usbmount to create the folders usb[0-7] only when the specific device is attached and not permanently?
/etc/fstab
described here work in your case? You would need some modifications for example some mount options for your particular case. Or maybe usingmount
via a script more or less automatically similar to what is described there? -- But I agree with mook, that there are problems with this idea: 1. risk with sensitive data; 2. A USB stick is not reliable enough for backup, I would suggest a USB HDD or USB SSD. – sudodus Jul 04 '22 at 13:34/dev/sdb1
to a fixed permanent name under/media
or another mount point in the users home directory using theudisks
utility. – Raffa Jul 04 '22 at 18:42