# Mounting USB Flash Drive



## newbsdkv (Jan 27, 2019)

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

```
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!


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


```
/etc/rc.conf:
devfs_system_ruleset="localrules"
```


----------



## Bojan Petrović (Jan 27, 2019)

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:


```
# devfs rule showsets
1
2
3
4
5
# devfs rule -s 5 show
100 path da*s* group operator mode 660
```

Regards,
Bojan


----------



## newbsdkv (Jan 27, 2019)

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 ...



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


```
less /etc/rc.conf
devfs_system_ruleset="localrules"
```


```
# devfs rule showsets
1
2
3
4
5
10
```


```
devfs rule -s 5 show
100 path da*s* group operator mode 660
200 path da* group operator mode 660
```


```
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ć (Jan 28, 2019)

Thanks four your feedback.

Could you please provide some more information?


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.
When you run `devfs rule -s 5 applyset`, do the permissions look OK?
Can you send the output of `sh -x /etc/rc.d/devfs restart`?

Regards,
Bojan


----------



## newbsdkv (Jan 29, 2019)

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...


```
# 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
```


```
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


```
# 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
```


```
I have also deleted the system ruleset from /etc/rc.conf. Restarted devfs and it works fine :)!

Thanks again
```


----------



## Bojan Petrović (Jan 29, 2019)

Cool, glad that you managed to fix it!


----------

