In a typical GUI file manager, like PCManFM, I can mount a USB drive by simply clicking on its icon. Is there a similar command I can use which automatically creates a directory in the right place (/media/USER/label) before it mounts the drive? I use Debian 9.
Easy USB disk mount command
mountusb-drive
Related Solutions
Udev manages devices via rules that determine what to do when a device is inserted (or removed). Udev itself doesn't handle mounting, but you can make it invoke an external program to do the mounting.
There are rules, stored in the various files under /etc/udev/rules.d/
, that create entries in /dev/disk/by-label/
. We can use the same matching conditions to match a USB device which has a filesystem label and run a custom script.
ENV{ID_FS_LABEL_ENC}=="?*", ENV{ID_FS_USAGE}=="filesystem|other", \
SUBSYSTEMS=="usb", \
RUN += "/usr/local/sbin/udev-mount-by-label '%E{ID_FS_LABEL_ENC}'"
The custom script should create the mount point and perform the mounting. It should take a bit of care in case the directory already exists. The script I've written will do nothing if the mount point is already in use as a mount point, but will happily shadow a non-empty directory. Customize to your taste.
#!/bin/sh
export mount_point="/media/$1"
current_device=$(awk '$2 == ENVIRON["mount_point"] {print $1; exit}' </proc/mounts)
if [ -n "$current_device" ]; then
echo 1>&2 "$current_device already mounted on $mount_point"
exit 1
fi
mount "/dev/disk/by-label/$1" "$mount_point"
Don't forget to unmount the device before unplugging it, otherwise you may lose data.
Ubuntu - Automatically mount external drives to /media/LABEL on boot without a user logged in? shows the same technique with a different script.
UAS is a method of transfer with less overhead using SCSI encapsulated into USB, but is prone to issues and incompatibilities between some hardware/vendor/firmware/os (pick among).
You should disable UAS because it's certainly the cause of incompatibility with your combination of hardware/os (also see later what I really mean).
You can use a blacklist to disable it only for known failing devices. This kernel documentation (look for usb-storage.quirks=) tells what are the options to work around various issues with USB storage.
Your device is identified as USB VID:PID 0bc2:231a
, and the string :u
is added to disable USB UAS.
Usually that would be by creating in /etc/modprobe.d/
a file called local-disable-seagate-uas.conf
with this content:
options usb-storage quirks=0bc2:231a:u
Then something like update-initramfs -u
and rebooting (unless you know how to and can remove some usb modules and then reload them) should be done.
Alternatively, if you can't write there (Live CD, chicken-and-eggs problem and so on...) or if usb-storage is compiled not as module, you have to add it as a kernel boot parameter. That parameter would then be:
usb-storage.quirks=0bc2:231a:u
Look at the Knoppix documentation (Boot options and controls) for how to do this.
Now once you confirm it fixes the issue, what you should really do is upgrade your OS with something more recent. Kernel 3.3 is way too old and unsupported anywhere and it's probable some UAS issues got fixed since then. Once you got a recent OS (eg: Debian 9, or Knoppix 8.1 to stay similar) you should try again, carefully, with and without this parameter and see what works best. Some problems can happen only under heavy load, talking from experience.
Best Answer
udisks2
Example
mounts 1. Partition from /dev/sdb
udisks