rbrito / usbmount

Simple set of scripts to automount removable devices for a Linux system
275 stars 86 forks source link

Mount failed, reason unclear #32

Open RBJRBJ opened 3 years ago

RBJRBJ commented 3 years ago

Running usbmount on Ubuntu 18.04 on a Raspberry Pi 4: $ uname -a Linux hfpsrv-simu 5.4.0-1025-raspi #28~18.04.1-Ubuntu SMP PREEMPT Thu Dec 10 03:37:31 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

Fails to auto mount, see syslog:

Dec 21 09:53:47 hfpsrv-simu usbmount[1820]: /dev/sda2 contains filesystem type ext4 Dec 21 09:53:47 hfpsrv-simu usbmount[1820]: mountpoint /media/sandisk is available for /dev/sda2 Dec 21 09:53:47 hfpsrv-simu usbmount[1820]: executing command: mount -text4 /dev/sda2 /media/sandisk Dec 21 09:53:47 hfpsrv-simu systemd[1]: usbmount@dev-sda2.service: Main process exited, code=exited, status=1/FAILURE Dec 21 09:53:47 hfpsrv-simu systemd[1]: usbmount@dev-sda2.service: Failed with result 'exit-code'. Dec 21 09:53:47 hfpsrv-simu systemd[1]: Failed to start usbmount@dev-sda2.service.

$ sudo systemctl status usbmount@dev-sda2.service ● usbmount@dev-sda2.service Loaded: loaded (/lib/systemd/system/usbmount@.service; static; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2020-12-21 09:53:47 UTC; 1h 23min ago Process: 1820 ExecStart=/usr/share/usbmount/usbmount add (code=exited, status=1/FAILURE) Main PID: 1820 (code=exited, status=1/FAILURE)

Dec 21 09:53:47 hfpsrv-simu systemd[1]: Starting usbmount@dev-sda2.service... Dec 21 09:53:47 hfpsrv-simu usbmount[1833]: trying to acquire lock /var/run/usbmount/.mount.lock Dec 21 09:53:47 hfpsrv-simu usbmount[1840]: acquired lock /var/run/usbmount/.mount.lock Dec 21 09:53:47 hfpsrv-simu systemd[1]: usbmount@dev-sda2.service: Main process exited, code=exited, status=1/FAILURE Dec 21 09:53:47 hfpsrv-simu systemd[1]: usbmount@dev-sda2.service: Failed with result 'exit-code'. Dec 21 09:53:47 hfpsrv-simu systemd[1]: Failed to start usbmount@dev-sda2.service.

Manually mounting works fine: $ sudo mount -text4 /dev/sda2 /media/sandisk $ df -h Filesystem Size Used Avail Use% Mounted on ... /dev/sda2 14G 256M 13G 2% /media/sandisk

Any ideas?

mpashka commented 3 years ago

TLDR: Current version already has appropriate changes but raspberry repository still has very old version (2011) and appropriate changes were made in 2017. So solution is take latest version, build as described in readme and install manually.

Reason is described here: https://unix.stackexchange.com/a/551952/240004 In a recent versions of systemd, the udev service file has SystemCallFilter=@system-service @module @raw-io. This doesn't allow the system calls required to mount a filesystem.

Possible fix is to reimplement usbmount as a service rather than raw executable file. Example for arch linux (russian): https://wiki.archlinux.org/index.php/USB_storage_devices_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)#.D0.90.D0.B2.D1.82.D0.BE.D0.BC.D0.BE.D0.BD.D1.82.D0.B8.D1.80.D0.BE.D0.B2.D0.B0.D0.BD.D0.B8.D0.B5_.D1.81_.D0.B8.D1.81.D0.BF.D0.BE.D0.BB.D1.8C.D0.B7.D0.BE.D0.B2.D0.B0.D0.BD.D0.B8.D0.B5.D0.BC_systemd

Also it is possible to use udisks2 or udevil. Strange thing is udevil claims as a tiny udisks2 replacement but udevil package also requires udisks2. I tried to Use this solution https://holyhead.de/index.php?title=Raspberry_Pi#External_USB_drives with this udev rule https://github.com/souramoo/OpenELECconfig/blob/master/udev.rules.d/95-udevil-mount.rules but it still doesn't work since there is no udevil-mount service installed by udevil.

So issue can be closed.