devfs restart Causes Warning, Mounting USBs is Awful Experience

I'm following the 17.4 Handbook guide for USBs. I understand about /etc/devfs.rules and /etc/rc.conf requirements. I add devfsrules_localrules=5] , and then in rc.conf devfs_system_ruleset="localrules". I do ALL of the other stuff as well. vfs.usermount=1. Double, triple, quadruple check. Reboot...

But when I apply service devfs restart I get the following:

Code:
/etc/rc.d/devfs: WARNING: devfs_set_ruleset: you must specify a ruleset number
/etc/rc.d/devfs: WARNING: devfs_apply_ruleset: you must specify a ruleset

So I tried just setting rc.conf to one of the predefined rulesets "jail", for example. Same deal. So I looked in /etc/defaults/rc.conf, and saw an option for devfs_set_rulesets="", so I tried adding devfs_set_rulesets="" to a few different values, each time restarting devfs. Values: "localrules" "5" "/etc/devfs.rules" "/etc/fstab" and each time it did nothing, except for sometimes throw additional errors. I tried enabling debugging. Nothing useful, it loads all the rules, and then the exact same 2 warnings at the bottom.

While the rest of my FreeBSD experience has been quite good, mounting and automounting USBs has been awful, and consistently awful (I've reinstalled a few times). The documentation seems to be incomplete, and apparently just wrong. Finding out a straightforward way to mount ext4 USBs is like pulling teeth. Yeah I get it now, pkg install fusefs-lkl fuse_load="YES", because the inbuilt function in the kernel doesn't work well. There's like 5 different things going on that I can't really make sense of ... autofs automount automountd autoumount lklfuse. COULD SOMEONE POSSIBLY UPDATE THE HANDBOOK??

I'm sorry if I sound angry or frustrated. But while the other snags I've hit were user error or just having to learn the system's intricacies, I'm pretty sure the warnings being thrown here aren't due to lack of following the handbook or reasonable attempted troubleshooting. I've read perhaps a dozen different manpages on this stuff with very little progress. YES, I have been reading/searching through forum posts. NO, very little has been useful expect this one: https://forums.freebsd.org/threads/...g-with-zfs-root-freebsd-12.70401/#post-424036
 
Last edited by a moderator:
I tend to not bother with the usermount stuff. I even think OpenBSD had the right idea removing it :/

Have you considered just using sudo? With a small bit of config in your sudoers file you could even set it up so that a password is never asked for mount related commands.

I wrote an awk script (that re-runs itself with sudo if it detects that it is not being run as root) that lists all available devices and partitions, and if called with an argument will mount it under /mnt/<device><partition>. A bit of a pain to write initially but you only need to do it once!

Also, try to mount using the native tools first (i.e a msdosfs partition) and get that working before you move onto fuse. Since fuse is largely userland it introduces a few quirks (possibly to the usermount stuff you are experiencing)
 
I'm doing this in a bhyve VM, with pci passthrough for the USB bus. This protects the host OS, and helps to isolate the hardware controllers in the case of potentially malicious mass storage devices.

I will be ssh'ing into the VM from jails where I want the desired files to go.

Thanks for your suggestions, maybe I will use them as a workaround if absolutely necessary. But in reality, there are still 2 fundamental problems:

1. Whether from host or from bhyve VM, setting devfs_system_ruleset="<rulename>" seems broken, after running service devfs restart

and

2. The Handbook on USB mass storage devices is overly complicated, incomplete, and wrong
 
Using sysutils/fusefs-ntfs from packages
I have in /etc/rc.conf
Code:
devfs_system_ruleset="localrules"

in /etc/sysctl.conf
Code:
vfs.usermount=1
in /etc/devfs.conf
Code:
[localrules=1]
add path 'da/*' mode 0660 group operator
and in /boot/loader.conf
Code:
fuse_load="YES"
and haven't experienced any issues, but I don't automount anything. I issue mount and umount commands as needed.
 
Using sysutils/fusefs-ntfs from packages
I have in /etc/rc.conf
Code:
devfs_system_ruleset="localrules"

in /etc/sysctl.conf
Code:
vfs.usermount=1
in /etc/rc.conf
Code:
[localrules=1]
add path 'da/*' mode 0660 group operator
and in /boot/loader.conf
Code:
fuse_load="YES"
and haven't experienced any issues, but I don't automount anything. I issue mount and umount commands as needed.

ok... have you tried service devfs restart ? I too have fuse_load in loader.conf
did you miss the part where I talk about automounting?
 
Here a service restart was successful but I received the error messages you cited on an attempt to restart the service as a user. Have you changed any file permissions on /etc/devfs.conf or /etc/rc.d/devfs?
 
Nope. It's a brand new virtual machine. But I get the same error as root on the host as well ... luckily I don't need to change host devfs system rules
 
I'm following the 17.4 Handbook guide for USBs. I understand about /etc/devfs.rules and /etc/rc.conf requirements. I add [devfsrules_localrules=5] , and then in rc.conf devfs_system_ruleset="localrules". I do ALL of the other stuff as well. vfs.usermount=1. Double, triple, quadruple check. Reboot...

But when I apply service devfs restart I get the following:

Code:
/etc/rc.d/devfs: WARNING: devfs_set_ruleset: you must specify a ruleset number
/etc/rc.d/devfs: WARNING: devfs_apply_ruleset: you must specify a ruleset

So I tried just setting rc.conf to one of the predefined rulesets "jail", for example. Same deal. So I looked in /etc/defaults/rc.conf, and saw an option for "devfs_set_rulesets="", so I tried adding devfs_set_rulesets="" to a few different values, each time restarting devfs. Values: "localrules" "5" "/etc/devfs.rules" "/etc/fstab" and each time it did nothing, except for sometimes throw additional errors. I tried enabling debugging. Nothing useful, it loads all the rules, and then the exact same 2 warnings at the bottom.

While the rest of my FreeBSD experience has been quite good, mounting and automounting USBs has been awful, and consistently awful (I've reinstalled a few times). The documentation seems to be incomplete, and apparently just wrong. Finding out a straightforward way to mount ext4 USBs is like pulling teeth. Yeah I get it now, `pkg install fusefs-lkl` `fuse_load="YES"`, because the inbuilt function in the kernel doesn't work well. There's like 5 different things going on that I can't really make sense of ... autofs automount automountd autoumount lklfuse. COULD SOMEONE POSSIBLY UPDATE THE HANDBOOK??

I'm sorry if I sound angry or frustrated. But while the other snags I've hit were user error or just having to learn the system's intricacies, I'm pretty sure the warnings being thrown here aren't due to lack of following the handbook or reasonable attempted troubleshooting. I've read perhaps a dozen different manpages on this stuff with very little progress. YES, I have been reading/searching through forum posts. NO, very little has been useful expect this one: https://forums.freebsd.org/threads/...g-with-zfs-root-freebsd-12.70401/#post-424036
Is your user a member of the operator group? If not, it must be.
Could you list all the da* devices, please?
Did you type this correctly: [devfsrules_localrules=5] ??
The two should match, so enabling "localrules" in /etc/rc.conf is not matching your rule name devfsrules_localrules.

And as kpedersen pointed out, rightly I think, I'd steer away from user mounted stuff.
 
Ok that was it. As you said, "devfsrules_localrules." Somehow I had it in my head that the full name was "localrules," even with the prepending "devfsrules_" in the devfs.rules file. Basically, it needs to be the same in both rc.conf and devfs.rules ...

[localrules=5] with rc.conf entry devfs_system_ruleset="localrules" ...or...
[devfsrules_localrules=5] with rc.conf entry devfs_system_ruleset="devfsrules_localrules"

Thank you for your help.
 
I am going to make user enabled usb though. As I've said before, this is a bhyve VM with pci passthrough for the USB. Not network connected, except for the tap going to my selected jail for the ssh operation (all on one host).

I intend to ssh into the machine for copying files to jails on the host. So either I have to enable usermount usb, enable ssh root logins, or set up sudo/doas so I can mount after login from ssh. The simpler solution is to allow usermount
 
Ok that was it. As you said, "devfsrules_localrules." Somehow I had it in my head that the full name was "localrules," even with the prepending "devfsrules_" in the devfs.rules file. Basically, it needs to be the same in both rc.conf and devfs.rules ...

[localrules=5] with rc.conf entry devfs_system_ruleset="localrules" ...or...
[devfsrules_localrules=5] with rc.conf entry devfs_system_ruleset="devfsrules_localrules"

Thank you for your help.
No problems. Sometimes it just takes someone else to look over your work to find the bleeding obvious.
I know, I've been there before. ;)
 
I just ran across this myself: I found I didn't have the file /etc/devfs.rules

Code:
/etc/rc.d/devfs: WARNING: devfs_set_ruleset: you must specify a ruleset number
/etc/rc.d/devfs: WARNING: devfs_apply_ruleset: you must specify a ruleset

I created the file /etc/devfs.rules and added what I needed for virtualbox:

Code:
[system=10]
add path 'usb/*' mode 0660 group operator

Then I ran
Code:
GhettoNAS [~] > service devfs restart

And that worked for me.
 
Last edited by a moderator:
Back
Top