5

As the title suggests, I am having issues on the new raspberry pi 4 with buster and USBMOUNT. Well, it's not working. At 3b+ there was a similar issue, you had to edit a file and change MountFlags from slave to shared. Well there isn't a MountFlags setting in the systemd-udevd.service file, but no matter what, I added it but still not working. Any ideas or an alternative to usbmount for a headless setup, keeping in mind that not always the usb stick is mounted and ofcourse it's not always the same stick with the same label all the time.

My dmesg:

I plug the stick somewhere here
[   41.511528] usb 1-1.2: new high-speed USB device number 8 using xhci_hcd
[   41.647482] usb 1-1.2: New USB device found, idVendor=26bd, idProduct=9917, bcdDevice= 1.00
[   41.647497] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   41.647509] usb 1-1.2: Product: SecureLock
[   41.647521] usb 1-1.2: Manufacturer:
[   41.647532] usb 1-1.2: SerialNumber: 0700413066DDE445
[   41.649386] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[   41.661890] scsi host0: usb-storage 1-1.2:1.0
[   42.733384] scsi 0:0:0:0: Direct-Access              SecureLock       PMAP PQ: 0 ANSI: 4
[   42.734206] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   43.843400] sd 0:0:0:0: [sda] 15124992 512-byte logical blocks: (7.74 GB/7.21 GiB)
[   43.843621] sd 0:0:0:0: [sda] Write Protect is off
[   43.843636] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[   43.843866] sd 0:0:0:0: [sda] No Caching mode page found
[   43.843879] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   43.866878]  sda: sda1

and my df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.0G  1.4G  1.5G  48% /
devtmpfs        334M     0  334M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  6.3M  457M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
tmpfs           100M  8.0K  100M   1% /var/log
tmpfs            30M     0   30M   0% /var/tmp
tmpfs           100M  4.0K  100M   1% /tmp
tmpfs            20M  956K   20M   5% /run/samba
tmpfs            20M  1.3M   19M   7% /var/cache/samba
tmpfs            30M     0   30M   0% /tmp/mqueue
/dev/mmcblk0p1  253M   40M  213M  16% /boot
/dev/mmcblk0p3  438M  4.6M  406M   2% /home
tmpfs            93M     0   93M   0% /run/user/0

Finally, my fdisk -l

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1         8192  532480  524289  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       540672 6832127 6291456    3G 83 Linux
/dev/mmcblk0p3      6832128 7774207  942080  460M 83 Linux


Disk /dev/sda: 7.2 GiB, 7743995904 bytes, 15124992 sectors
Disk model: SecureLock
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fb5e9d8

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8064 15124991 15116928  7.2G  c W95 FAT32 (LBA)

This setup is working on a raspberry pi 2, pi 3b (jessie), pi 3b+ (stretch)

7

I faced the same issue with Raspberry Pi 4 and Raspbian Buster, the solution for me was to modify the following file:

/lib/systemd/system/systemd-udevd.service

Before: PrivateMounts=yes

After: PrivateMounts=no

Then I rebooted and it was OK ;)

|improve this answer|||||
  • I do not understand this. What does Before and After mean? Before setting private file system (mount) namespace (PrivateMounts=yes: man systemd.exec)? As far as I understand this option is not an event you can trigger Before. Before and After are options for the [Unit] section. In what section do you set these options? In the [Service] section? – Ingo Jul 7 '19 at 9:06
  • 1
    Thanks a lot mate. – papatrexas Jul 8 '19 at 7:52
  • @Ingo Sorry if my wording was not so clear, I was just meaning before and after the modification, in other words you just have to change "yes" to "no" for this "PrivateMounts" parameter in the "[Service]" section. – Greg Jul 8 '19 at 10:32
  • Ah.. Ok. Can you that please add to your answer to clarify? – Ingo Jul 8 '19 at 11:00
3

Because Raspbian is based on Debian, I suggest you to create a permanent system-specific configuration file according to the definitions as given in Debian's policies (see https://www.debian.org/doc/debian-policy/ch-files.html#configuration-files).

Buster has a solid configuration for systemd and udev placed in the package's library files at /lib/systemd/system/systemd-udevd.service. But as opposed to Greg's anwser this is not the place to change the configuration. It's very likely, that the changes you did, will be silently overwritten by an upgrade of the system's packages done by the packet manager. Only files in /etc/systemd/system are meant to be a system-specific configuration change done by an operator and not by a package (for further explanation see https://unix.stackexchange.com/a/458252/85199).

Therefor if you want to make usbmount work again, the already given configuration syntax is right. But you should place it like this.

Create a configuration container directory /etc/systemd/system/systemd-udevd.service.d.

sudo mkdir /etc/systemd/system/systemd-udevd.service.d

Create an own confugration file (that will overwrite the package configuration). Change 00-my-custom-mountflags as you wish.

sudo nano -w /etc/systemd/system/systemd-udevd.service.d/00-my-custom-mountflags.conf

Enter the following configuration, which disables private mounts.

[Service]
PrivateMounts=no

Restart systemd and udev subprocesses (or simply reboot).

sudo systemctl daemon-reexec
sudo service systemd-udevd restart

This way usbmount will work again like expected, your configuration file is persisted and not silently replaced by an apt upgrade.

I've done it this way for Pi 4 B with Raspbian Buster and can confirm that it works.

|improve this answer|||||
  • I agree that this is the correct workflow. As an alternative to your 'sudo nano' step, I used instead the command 'systemctl edit systemd-udevd'. This opens file '/etc/systemd/system/systemd-udevd.service.d/override.conf' in a VI editor. I added the '[Service] ...' section as you described, saved the changes, and restarted the systemd and udev subprocesses as described. Worked great. – Jim Fischer Mar 10 at 23:14
2

Please use Greg's solution. I don't know if mods wish to remove this

SO.... I am currently using pmount. Removed USBMOUNT and installed it using the instructions here: https://raspberrypi.stackexchange.com/a/66324/68240 "thanks to the original author btw"

The only extra was that I had to

sudo chmod +x /usr/local/bin/cpmount

Since it was not working at the beginning and before the chmod, I created the mounting folders my self. So I am not sure if you actually need to do that. I also edited the script and changed the folder numbering and finally I removed the --sync setting.

Hope this helps someone, it looks like USBMOUNT is not being developed any more.

Oh oh forgot to mention. I did this before creating the script and right after I installed pmount, so I again I am not sure if it is actually required. Should be though.

sudo pico /etc/pmount.allow

and add there the devices you allow pmount to use /dev/sda1 /dev/sda2 and so on...

|improve this answer|||||
  • usbmount is exactly the kind of script that your custom-written cpmount is, packaged together with the udev rule. While it's old, I don't see how a self-written solution is any better. – Dmitry Grigoryev Feb 27 at 12:57
0

I have a Raspberry Pi 4, running Buster, and I successfully installed usbmount following the instructions at ...

https://www.linuxuprising.com/2019/04/automatically-mount-usb-drives-on.html

which in summary says:

sudo apt install git
git clone https://github.com/rbrito/usbmount
sudo apt install debhelper build-essential
cd usbmount
dpkg-buildpackage -us -uc -b

The only change I made was after all those commands and BEFORE installing the .deb file I did this:

sudo apt install lockfile-progs

and then installed like this

cd ..     # back to where you were
sudo dpkg -i usbmount_0.0.24_all.deb 
|improve this answer|||||
  • Please don't write answers that can only be understood by following a link. – Ingo Feb 28 at 11:23
  • Sorry if I offended. I was trying to help other people in my situation. – Andrew Kay Feb 29 at 12:04
  • 1
    I have now fixed it up to include a summary of the remote link. – Andrew Kay Feb 29 at 12:10
  • 1
    +1, well done (according to our policies) :-) – Ingo Mar 1 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.