Mounting USB Flash Drive

newbsdkv

New Member

Reaction score: 1
Messages: 15

Hello All,

Quick question regarding permissions on a USB Flash Drive...

When I plug in my USB flash drive as a normal user in the operator group, I get the following permissions for all partitions in /dev/da0
Code:
crw-r-----  1 root      operator  0x7b Jan 26 16:39 da0
crw-r-----  1 root      operator  0x7c Jan 26 16:39 da0s1
Which is basically rw for owner and read-only for group. In order to mount and write to my flash drive I have to change permissions to chmod 660 /dev/da0*. Things work fine after this.

I have the following in my /etc/devfs.rules and /etc/rc.conf. Shouldn't this automatically change permissions to "660" when I plug my flash drive, without having to do a "chmod"? Or am I understanding this incorrectly?

Thanks much!

Code:
/etc/devfs.rules:
[localrules=5]
add path 'da*' mode 0660 group operator
Code:
/etc/rc.conf:
devfs_system_ruleset="localrules"
 
Last edited by a moderator:

Bojan Petrović

New Member

Reaction score: 8
Messages: 13

Hi,

Have you restarted the devfs service? You can do it either with service devfs restart, or /etc/rc.d/devfs restart.

You can check if the /etc/devfs.rules are being picked up with devfs(8). The output should be something like:

Code:
# devfs rule showsets
1
2
3
4
5
# devfs rule -s 5 show
100 path da*s* group operator mode 660
Regards,
Bojan
 
OP
OP
N

newbsdkv

New Member

Reaction score: 1
Messages: 15

Thanks Bojan!

The following is my latest configuration. I made some small changes to /etc/devfs.rules to include da* and all its partitions. Rebooted the system to make sure the changes were applied. Devfs appears to be seeing the rules (please see output below). However. the permissions are still the same! This is a little puzzling :)...


Code:
# less /etc/devfs.rules
[localrules=5]
add path 'da*s*' mode 0660 group operator
add path 'da*' mode 0660 group operator
Code:
less /etc/rc.conf
devfs_system_ruleset="localrules"
Code:
# devfs rule showsets
1
2
3
4
5
10
Code:
devfs rule -s 5 show
100 path da*s* group operator mode 660
200 path da* group operator mode 660
Code:
ls -l /dev | grep da0
crw-r-----  1 root      operator  0x86 Jan 27 12:40 da0
crw-r-----  1 root      operator  0x87 Jan 27 12:40 da0s1
 

Bojan Petrović

New Member

Reaction score: 8
Messages: 13

Thanks four your feedback.

Could you please provide some more information?

  1. Where is the rule number 10 written, and what is its name? You might be able to find it with grep -r '=10\]' /etc/. I'm wondering if it is named the same ("localrules"), and it if is used as devfs_system_ruleset, shadowing the rules in the ruleset number 5.
  2. When you run devfs rule -s 5 applyset, do the permissions look OK?
  3. Can you send the output of sh -x /etc/rc.d/devfs restart?

Regards,
Bojan
 
OP
OP
N

newbsdkv

New Member

Reaction score: 1
Messages: 15

Bojan,

You are absolutely right :)!

I made the mistake of having 2 competing rulesets. See snapshots of /etc/devfs.rules and /etc/rc.conf . As you can see from my rc.conf the "system" ruleset was overriding the "localrules" set...

Code:
# cat  /etc/devfs.rules
[localrules=5]
add path 'da*s*' mode 0660 group operator
add path 'da*' mode 0660 group operator

[system=10]
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
Code:
cat /etc/rc.conf

devfs_system_ruleset="localrules"

# printing
cupsd_enable="YES"
devfs_system_ruleset="system"
I have now made changes to both files as follows

Code:
# cat /etc/devfs.rules
[localrules=5]
add path 'da*s*' mode 0660 group operator
add path 'da*' mode 0660 group operator
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
Code:
I have also deleted the system ruleset from /etc/rc.conf. Restarted devfs and it works fine :)!

Thanks again
 
Top