I have tried to configure usbmount
to automatically mount ntfs
(and other file systems, like vfat
and hfsplus
which all work as expected) devices. Here is my /etc/usbmount/usbmount.conf
file:
# Configuration file for the usbmount package, which mounts removable
# storage devices when they are plugged in and unmounts them when they
# are removed.
# Change to zero to disable usbmount
ENABLED=1
# Mountpoints: These directories are eligible as mointpoints for
# removable storage devices. A newly plugged in device is mounted on
# the first directory in this list that exists and on which nothing is
# mounted yet.
MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
/media/usb4 /media/usb5 /media/usb6 /media/usb7"
# Filesystem types: removable storage devices are only mounted if they
# contain a filesystem type which is in this list.
FILESYSTEMS="exfat vfat ext2 ext3 ext4 hfsplus ntfs fuseblk ntfs-3g"
#############################################################################
# WARNING! #
# #
# The "sync" option may not be a good choice to use with flash drives, as #
# it forces a greater amount of writing operating on the drive. This makes #
# the writing speed considerably lower and also leads to a faster wear out #
# of the disk. #
# #
# If you omit it, don't forget to use the command "sync" to synchronize the #
# data on your disk before removing the drive or you may experience data #
# loss. #
# #
# It is highly recommended that you use the pumount command (as a regular #
# user) before unplugging the device. It makes calling the "sync" command #
# and mounting with the sync option unnecessary---this is similar to other #
# operating system's "safely disconnect the device" option. #
#############################################################################
# Mount options: Options passed to the mount command with the -o flag.
# See the warning above regarding removing "sync" from the options.
MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"
# Filesystem type specific mount options: This variable contains a space
# separated list of strings, each which the form "-fstype=TYPE,OPTIONS".
#
# If a filesystem with a type listed here is mounted, the corresponding
# options are appended to those specificed in the MOUNTOPTIONS variable.
#
# For example, "-fstype=vfat,gid=floppy,dmask=0007,fmask=0117" would add
# the options "gid=floppy,dmask=0007,fmask=0117" when a vfat filesystem
# is mounted.
FS_MOUNTOPTIONS=""
# If set to "yes", more information will be logged via the syslog
# facility.
VERBOSE=yes
However when plugging in a ntfs
formatted thumb drive, the command ls -l /media
⛔️ gives the following error message:
ls: cannot access '/media/usb0': Transport endpoint is not connected
total 28
d????????? ? ? ? ? ? usb0
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb1
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb2
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb3
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb4
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb5
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb6
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb7
Syslog:
cat /var/log/syslog | grep usbmount
Apr 24 15:41:35 raspberrypi usbmount[5298]: loaded usbmount configurations
Apr 24 15:41:35 raspberrypi usbmount[5298]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5298]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5298]: /dev/sda does not contain a filesystem or disklabel
Apr 24 15:41:35 raspberrypi systemd-udevd[5297]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:41:35 raspberrypi usbmount[5320]: loaded usbmount configurations
Apr 24 15:41:35 raspberrypi usbmount[5320]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5320]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5320]: /dev/sda1 contains filesystem type ntfs
Apr 24 15:41:35 raspberrypi usbmount[5320]: mountpoint /media/usb0 is available for /dev/sda1
// Logs the mount command that was executed
Apr 24 15:41:40 raspberrypi usbmount[5320]: executing command: mount -tntfs -osync,noexec,nodev,noatime,nodiratime /dev/sda1 /media/usb0
Apr 24 15:41:41 raspberrypi usbmount[5320]: executing command: run-parts /etc/usbmount/mount.d
Apr 24 15:41:41 raspberrypi usbmount[5320]: usbmount execution finished
Here's the part I don't understand. When executing the mount command manually in a terminal, everything works as expected!
sudo mount -tntfs -osync,noexec,nodev,noatime,nodiratime /dev/sda1 /media/usb0
ls -l /media
✅
total 32
drwxrwxrwx 1 root root 4096 Apr 24 15:29 usb0
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb1
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb2
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb3
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb4
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb5
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb6
drwxr-xr-x 2 root root 4096 Apr 23 10:18 usb7
The error message in ls
disappears and all files can be accessed.
Any ideas on how to make it work automatically? I have tried reading the source code of usbmount on Github, but have not found anything useful.
Additional Requested Information
systemctl status systemd-udevd.service
● systemd-udevd.service - udev Kernel Device Manager
Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
Active: active (running) since Wed 2019-04-24 15:24:01 BST; 1 day 18h ago
Docs: man:systemd-udevd.service(8)
man:udev(7)
Main PID: 126 (systemd-udevd)
Status: "Processing with 16 children at max"
CGroup: /system.slice/systemd-udevd.service
└─126 /lib/systemd/systemd-udevd
Apr 24 16:15:30 raspberrypi mtp-probe[6050]: checking bus 1, device 13: "/sys/devices/platform/soc/3
Apr 24 16:15:31 raspberrypi usbmount[6059]: loaded usbmount configurations
Apr 24 16:15:31 raspberrypi systemd-udevd[6056]: Process '/usr/share/usbmount/usbmount add' failed w
Apr 24 16:15:31 raspberrypi usbmount[6081]: loaded usbmount configurations
Apr 24 16:15:31 raspberrypi usbmount[6086]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 16:15:31 raspberrypi usbmount[6102]: /dev/sda1 contains filesystem type vfat
Apr 24 16:15:32 raspberrypi usbmount[6133]: usbmount execution finished
Apr 25 12:59:45 raspberrypi mtp-probe[7615]: checking bus 1, device 14: "/sys/devices/platform/soc/3
Apr 25 12:59:47 raspberrypi systemd-udevd[7620]: Process '/usr/share/usbmount/usbmount add' failed w
Apr 25 12:59:47 raspberrypi usbmount[7697]: usbmount execution finished
journalctl -u systemd-udevd.service
-- Logs begin at Thu 2016-11-03 17:16:42 GMT, end at Fri 2019-04-26 10:01:50 BST. --
Apr 24 15:24:01 raspberrypi systemd[1]: Starting udev Kernel Device Manager...
Apr 24 15:24:01 raspberrypi systemd[1]: Started udev Kernel Device Manager.
Apr 24 15:24:01 raspberrypi usbmount[189]: loaded usbmount configurations
Apr 24 15:24:02 raspberrypi usbmount[201]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:24:02 raspberrypi usbmount[204]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:24:02 raspberrypi systemd-udevd[149]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:24:07 raspberrypi ntfs-3g[258]: Version 2016.2.22AR.1 integrated FUSE 28
Apr 24 15:24:07 raspberrypi ntfs-3g[258]: Mounted /dev/sda1 (Read-Write, label "ntfs test", NTFS 3.1)
Apr 24 15:24:07 raspberrypi ntfs-3g[258]: Cmdline options: rw,sync,noexec,nodev,noatime,nodiratime
Apr 24 15:24:07 raspberrypi ntfs-3g[258]: Mount options: rw,sync,noexec,nodev,nodiratime,allow_other,nonempty,noatime,fsname=/dev/sda1,blkdev,blksize=4096
Apr 24 15:24:07 raspberrypi ntfs-3g[258]: Ownership and permissions disabled, configuration type 7
Apr 24 15:24:08 raspberrypi mtp-probe[301]: checking bus 1, device 3: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1"
Apr 24 15:24:08 raspberrypi mtp-probe[302]: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 15:24:08 raspberrypi mtp-probe[301]: bus: 1, device: 3 was not an MTP device
Apr 24 15:24:09 raspberrypi systemd-udevd[148]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:24:14 raspberrypi systemd-udevd[148]: Process '/usr/share/usbmount/usbmount add' failed with exit code 16.
Apr 24 15:25:02 raspberrypi mtp-probe[816]: checking bus 1, device 5: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 15:25:03 raspberrypi usbmount[830]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:25:03 raspberrypi usbmount[833]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:25:03 raspberrypi systemd-udevd[825]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:25:06 raspberrypi systemd-udevd[824]: spawned process '/usr/share/usbmount/usbmount add' [848] is taking longer than 49 years 3 months ago to complete
Apr 24 15:25:09 raspberrypi usbmount[891]: executing command: mount -thfsplus -osync,noexec,nodev,noatime,nodiratime /dev/sda1 /media/usb0
Apr 24 15:25:12 raspberrypi usbmount[957]: loaded usbmount configurations
Apr 24 15:25:12 raspberrypi usbmount[959]: usbmount execution finished
Apr 24 15:25:19 raspberrypi mtp-probe[985]: checking bus 1, device 6: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 15:25:20 raspberrypi usbmount[1005]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:25:20 raspberrypi systemd-udevd[997]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:25:26 raspberrypi usbmount[1063]: executing command: mount -tntfs -osync,noexec,nodev,noatime,nodiratime /dev/sda1 /media/usb0
Apr 24 15:25:26 raspberrypi ntfs-3g[1066]: Version 2016.2.22AR.1 integrated FUSE 28
Apr 24 15:25:26 raspberrypi ntfs-3g[1066]: Mounted /dev/sda1 (Read-Write, label "ntfs test", NTFS 3.1)
Apr 24 15:25:26 raspberrypi ntfs-3g[1066]: Cmdline options: rw,sync,noexec,nodev,noatime,nodiratime
Apr 24 15:25:26 raspberrypi ntfs-3g[1066]: Mount options: rw,sync,noexec,nodev,nodiratime,allow_other,nonempty,noatime,fsname=/dev/sda1,blkdev,blksize=4096
Apr 24 15:25:26 raspberrypi ntfs-3g[1066]: Ownership and permissions disabled, configuration type 7
Apr 24 15:25:33 raspberrypi systemd-udevd[1119]: inotify_add_watch(9, /dev/sda, 10) failed: No such file or directory
Apr 24 15:26:03 raspberrypi systemd-udevd[2527]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:26:08 raspberrypi ntfs-3g[3071]: Version 2016.2.22AR.1 integrated FUSE 28
Apr 24 15:26:08 raspberrypi ntfs-3g[3071]: Mounted /dev/sda1 (Read-Write, label "ntfs test", NTFS 3.1)
Apr 24 15:26:08 raspberrypi ntfs-3g[3071]: Cmdline options: rw,sync,noexec,nodev,noatime,nodiratime
Apr 24 15:26:08 raspberrypi ntfs-3g[3071]: Mount options: rw,sync,noexec,nodev,nodiratime,allow_other,nonempty,noatime,fsname=/dev/sda1,blkdev,blksize=4096
Apr 24 15:26:08 raspberrypi ntfs-3g[3071]: Ownership and permissions disabled, configuration type 7
Apr 24 15:26:24 raspberrypi usbmount[3303]: loaded usbmount configurations
Apr 24 15:26:24 raspberrypi usbmount[3305]: usbmount execution finished
Apr 24 15:30:43 raspberrypi mtp-probe[3358]: checking bus 1, device 8: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 15:30:45 raspberrypi systemd-udevd[3362]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:30:50 raspberrypi ntfs-3g[3434]: Version 2016.2.22AR.1 integrated FUSE 28
Apr 24 15:30:50 raspberrypi ntfs-3g[3434]: Mounted /dev/sda1 (Read-Write, label "", NTFS 3.1)
Apr 24 15:30:50 raspberrypi ntfs-3g[3434]: Cmdline options: rw,sync,noexec,nodev,noatime,nodiratime
Apr 24 15:30:50 raspberrypi ntfs-3g[3434]: Mount options: rw,sync,noexec,nodev,nodiratime,allow_other,nonempty,noatime,fsname=/dev/sda1,blkdev,blksize=4096
Apr 24 15:30:50 raspberrypi ntfs-3g[3434]: Ownership and permissions disabled, configuration type 7
Apr 24 15:41:29 raspberrypi usbmount[5267]: loaded usbmount configurations
Apr 24 15:41:34 raspberrypi mtp-probe[5292]: checking bus 1, device 9: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 15:41:35 raspberrypi usbmount[5302]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi systemd-udevd[5297]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 15:41:35 raspberrypi usbmount[5324]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5327]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 15:41:35 raspberrypi usbmount[5346]: mountpoint /media/usb0 is available for /dev/sda1
Apr 24 15:41:41 raspberrypi ntfs-3g[5351]: Version 2016.2.22AR.1 integrated FUSE 28
Apr 24 15:41:41 raspberrypi ntfs-3g[5351]: Mounted /dev/sda1 (Read-Write, label "", NTFS 3.1)
Apr 24 15:41:41 raspberrypi ntfs-3g[5351]: Cmdline options: rw,sync,noexec,nodev,noatime,nodiratime
Apr 24 15:41:41 raspberrypi ntfs-3g[5351]: Mount options: rw,sync,noexec,nodev,nodiratime,allow_other,nonempty,noatime,fsname=/dev/sda1,blkdev,blksize=4096
Apr 24 15:41:41 raspberrypi ntfs-3g[5351]: Ownership and permissions disabled, configuration type 7
Apr 24 16:10:37 raspberrypi mtp-probe[5460]: checking bus 1, device 10: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Apr 24 16:10:39 raspberrypi usbmount[5469]: loaded usbmount configurations
Apr 24 16:10:39 raspberrypi systemd-udevd[5466]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 16:10:39 raspberrypi usbmount[5516]: mountpoint /media/usb1 is available for /dev/sdb1
Apr 24 16:10:44 raspberrypi usbmount[5528]: executing command: run-parts /etc/usbmount/mount.d
Apr 24 16:13:21 raspberrypi usbmount[5714]: loaded usbmount configurations
Apr 24 16:13:21 raspberrypi usbmount[5715]: executing command: umount -l /media/usb0
Apr 24 16:13:22 raspberrypi usbmount[5736]: usbmount execution finished
Apr 24 16:13:27 raspberrypi usbmount[5745]: executing command: umount -l /media/usb1
Apr 24 16:13:27 raspberrypi usbmount[5747]: executing command: run-parts /etc/usbmount/umount.d
Apr 24 16:13:33 raspberrypi mtp-probe[5769]: checking bus 1, device 11: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 16:13:35 raspberrypi usbmount[5784]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 16:13:35 raspberrypi systemd-udevd[5776]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 16:13:35 raspberrypi usbmount[5803]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 16:13:35 raspberrypi usbmount[5806]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 16:13:40 raspberrypi usbmount[5837]: executing command: run-parts /etc/usbmount/mount.d
Apr 24 16:13:45 raspberrypi mtp-probe[5860]: checking bus 1, device 12: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Apr 24 16:13:46 raspberrypi usbmount[5870]: trying to acquire lock /var/run/usbmount/.mount.lock
Apr 24 16:13:46 raspberrypi usbmount[5873]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 16:13:46 raspberrypi systemd-udevd[5865]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 16:14:52 raspberrypi usbmount[5971]: executing command: umount -l /media/usb0
Apr 24 16:15:26 raspberrypi usbmount[6031]: executing command: run-parts /etc/usbmount/umount.d
Apr 24 16:15:26 raspberrypi usbmount[6043]: loaded usbmount configurations
Apr 24 16:15:30 raspberrypi mtp-probe[6050]: checking bus 1, device 13: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4"
Apr 24 16:15:31 raspberrypi usbmount[6059]: loaded usbmount configurations
Apr 24 16:15:31 raspberrypi systemd-udevd[6056]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 24 16:15:31 raspberrypi usbmount[6081]: loaded usbmount configurations
Apr 24 16:15:31 raspberrypi usbmount[6086]: acquired lock /var/run/usbmount/.mount.lock
Apr 24 16:15:31 raspberrypi usbmount[6102]: /dev/sda1 contains filesystem type vfat
Apr 24 16:15:32 raspberrypi usbmount[6133]: usbmount execution finished
Apr 25 12:59:45 raspberrypi mtp-probe[7615]: checking bus 1, device 14: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Apr 25 12:59:47 raspberrypi systemd-udevd[7620]: Process '/usr/share/usbmount/usbmount add' failed with exit code 1.
Apr 25 12:59:47 raspberrypi usbmount[7697]: usbmount execution finished
systemctl status systemd-udevd.service
. Can you please add the output to your question?