# USB and SD Card Problems: permissions and automount



## 240RBE (Nov 19, 2015)

Hello 

I have a problem regarding USB and SD card reader :

USB : automount works very well but I must be root to write or clear something, else I can just read.
SDCARD : sometimes automount works, and sometimes not. When It works, it is just readable and I must be root to write or erase files.
I tried to install and configure automount for these devices.

Let me introduce the configuration context:
My laptop: Lenovo X220 (core i7 version), FreeBSD 10.2.

/etc/rc.conf

```
devfs_system_ruleset="localrules"
autofs_enable="YES"
dbus-enable⁼"YES"
```
/etc/sysctl.conf

```
vfs.usermount="1"
```
I have created a rule set called "localrules" :

```
100 path da* group wheel mode 660
200 path cd* group wheel mode 660
300 path uscanner* group wheel mode 660
400 path xpt* group wheel mode 660
500 path pass* group wheel mode 660
600 path md* group wheel mode 660
700 path msdosfs/* group wheel mode 660
800 path ext2fs/* group wheel mode 660
900 path ntfs/* group wheel mode 660
1000 path usb/* group wheel mode 660
1100 path mmcsd*/* group wheel mode 660
```
I used to associate each rule to the operator group but it doesn't work, so I decided to put wheel group when I saw that da0 and mmcsd owner are root and the wheel group.

/usr/local/etc/automount.conf

```
USERUMOUNT=YES
MNTPREFIX="/media"
ATIME=NO
REMOVEDIRS=YES
FM="pcmanfm"
USER=me
#ENCODING=pl_PL.ISO8859-2
#CODEPAGE=cp852
```
I have added my user "me" to wheel group.

Regarding the SD card reader the `pciconf -lv` command returns this:

```
sdhci_pci0@pci0:13:0:0: class=0x088001 card=0x21da17aa chip=0xe8231180 rev=0x04 hdr=0x00
vendor     = 'Ricoh Co Ltd'
device     = 'PCIe SDXC/MMC Host Controller'
class      = base peripheral
```
Could you help me to know how I can get automount and r/w access permission for USB and SD cards?

Thank you in advance.


----------



## 240RBE (Nov 20, 2015)

My USB problem is resolved: I have created a folder me (username) in /mnt repertory then I declared me and operator as owners. Then I update my rules putting operator (I have erased wheel declaration), then I changed in /user/local/etc/automount.conf file by putting /mnt/me for MNTPREFIX. 

This gave me  R/W access in SD card  but it still doesn't work perfectly: it doesn't automount each time I plug in the SD card adapter in my internal reader .
When it doesn't work, It seems that the SD card reader works, and detect the memory card size but I can't access to it and files are not visible.

```
mmc0: <MMC/SD bus> on sdhci_pci0
mmcsd0: 4GB <SDHC SDC   1.0 SN 0026BD74 MFG 05/2011 by 3 0x0000> (read-only) at mmc0 25.0MHz/4bit/65535-block                                                         
g_vfs_done():mmcsd0s1[WRITE(offset=3188736, length=4096)]error = 30
g_vfs_done():mmcsd0s1[WRITE(offset=3188736, length=4096)]error = 30
```
Could you help me please.


----------



## Vadim_Mkk (Sep 26, 2019)

automount external  320GB USB  drive with NTFS for me was very very difficult task after setup FreeBSD.
Michael Lucas writes  in his book that external USB drivers is dangerous for server  and he doesn't describe this process. 
Handbook partition "17.4. USB Storage Devices"  contents instructions for server working  in the command line mode (CLI) - but this method doesn't work with GUI -  Xfce, Gnome and etc.
IMHO, but auto mount external USB with NTFS for GUI desktop   - it's shamanism  and shaman's dancing  with a tambourine around a bonfire with unpredictable result.  
Only persistent and thoughtful reading of this vermaden guide  helping to solve this problem


----------

