rbrito / usbmount

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

USBmount fails on Debian Stretch #2

Closed martignoni closed 6 years ago

martignoni commented 6 years ago

On Debian Stretch, USBmount doesn't work, notably with vfat formatted drives.

ravemir commented 6 years ago

I might be experiencing this, as well. From my experience, neither '/media/usb' drives displayed the expected content, nor did '/var/run/usbmount'.

Using fstab to target a mountpoint, while using the drive's UUID would not help, either.

ravemir commented 6 years ago

Disregard: after a reboot, the drive was mounted, possibly due to fstab itself.

But after unmounting, plugging off and in, the drive was successfully mounted automatically.

Not sure if expected, but both '/media/usb' and '/var/run/usbmount/' mountpoints were non-exiting, although that's likely due to being overriden by the fstab configurations.

@martignoni : have you tried this? if so, could you provide better details on what you have tried to get it to work?

martignoni commented 6 years ago

@ravemir: to make automount work, I had to drop USBmount (and that's too bad, as it works very well out of the box on Jessie), and use the mechanism used in project nextcloudpi. This works OK on stretch.

But I would be glad to revert to USBmount, for its simplicity of use.

42Swampy commented 6 years ago

Can you explain me, how to use the script. I made it executable and started it. Nothing happened. I am using raspbian stretch lite.

mmmmna commented 6 years ago

In support of ravemir's initial comment, no /var/run/usbmount, because usbmount is not installed (per Synaptic). I'm using (Debian derived) Point Linux 3.2 amd64.

georgejhunt commented 6 years ago

The udev version in stretch does not cooperate with usbmount as well as jessie did. Systemd-udevd.service unit file has an option in stretch which says "MountFlags=slave" which causes the mounted USB drive to disappear after the udev script terminates. Setting the line to "MountFlages=shared" returns the usbmount function to what worked in jessie.

martignoni commented 6 years ago

@georgejhunt Thanks for this info. Do you know a way to invoke this flag at runtime or is it necessary to change permanently the Systemd-udevd.service unit file? (I'm a bit reluctant to make a change that could break something elsewhere.)

georgejhunt commented 6 years ago

Changing a unit file requires running "systemctl daemon-reload" (or a reboot). But I don't know of a way to do it temporarily -- sort of 'on demand'. I think the reason for this change in udev, was to protect the privacy of the contents of a USB stick from other users on the system. Your use case might, or might not, require that feature. Since udev runs as root, and even root cannot see the mount, after udev retreats into the background, there is something I do not understand. You could experiment with setting the UID and GID in the usbmount config file.

On Tue, Sep 19, 2017 at 11:34 PM, Nicolas Martignoni < notifications@github.com> wrote:

@georgejhunt https://github.com/georgejhunt Thanks for this info. Do you know a way to invoke this flag at runtime or is it necessary to change permanently the Systemd-udevd.service unit file (I'm a bit reluctant to make a change that could break something elsewhere).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rbrito/usbmount/issues/2#issuecomment-330758389, or mute the thread https://github.com/notifications/unsubscribe-auth/AB04HK95-eGfwfznT153F70sSkEV8F9dks5skLHkgaJpZM4O8YJh .

martignoni commented 6 years ago

@georgejhunt: I implemented your suggested fix. It works as intended and doesn't seem to break anything. For reference, this answer on StackExchange details the process.

rbrito commented 6 years ago

If anybody has any suggestion and/or improvements that they want me to merge in a new release, please just send a pull request.

georgejhunt commented 6 years ago

Another issue on rpi with only some SD cards. Systemd-udevd.service is started when the rootfs is mounted ReadOnly. This causes efforts by the action scripts in /etc/usbmount/mount.d/ to be unable to write symbolic links (etc). The following unit file restarts the udevd later in the boot process when the file system is ReadWrite. Place this file in /etc/systemd/system/ and do "systemctl enable udev-reboot".

[Unit]
Description=Make sure udev is operating on ReadWrite disk
After=network-online.target

[Service]
ExecStart=/bin/systemctl restart systemd-udevd.service

[Install]
WantedBy=multi-user.target
martignoni commented 6 years ago

@rbrito Did you see pull request? Is there any chance that it get merged?

Cheers!

cinderblock commented 4 years ago

In case anyone runs across this issue now (like I did searching for solutions), the latest systemd (used in Buster) has changed this slightly. Now PrivateMounts=no is required instead of MountFlages=shared.

martignoni commented 4 years ago

@cinderblock: this issue was about Stretch support. Please refer to #25.