Unable to gain write access in samba share drive

Do you have the fat32 packages installed?

kmod-fs-vfat
dosfstools

Also what permissions is there on /mnt/sdb1 ?

Here's mine:

ls -l /mnt
drwxrwxrwx    5 root  root  4096 Jan 24 17:44 sda1
drwxrwxrwx    5 root  root  4096 Jan 24 17:44 sdb1

This command will give full permissions across all mounted volume sub-directories for sdb1:
chmod -R 777 /mnt/sdb1

kmod-fs-vfat is installed
dosfstools not installed

I have tried this command before, it's not seems to be doing anything. Permissions remains the same before and after sending the command.

drwxr-xr-x    2 root     root          4096 Dec 31 13:10 System Volume Information
drwxr-xr-x    2 root     root          4096 Feb 25 16:53 config
drwxr-xr-x    6 root     root          8192 Feb 25 23:01 temp

but what's the output after running the chmod command, using ls -l /mnt ?

also what output do you get for sdb1 running this command cat /proc/mounts?

 ls -l /mnt

drwxr-xr-x 8 root root 4096 Feb 26 10:15 sdb1

cat /proc/mounts

/dev/root /rom squashfs ro,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,noatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,noatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,noatime 0 0
/dev/mtdblock6 /overlay jffs2 rw,noatime 0 0
overlayfs:/overlay / overlay rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,size=512k,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,mode=600,ptmxmode=000 0 0
debugfs /sys/kernel/debug debugfs rw,noatime 0 0
/dev/sdb1 /mnt/sda1 exfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,namecase=0,errors=remount-ro 0 0

Does /mnt/sda1 even exist?

If it does exist, try chmod -R 777 /mnt/sda1

we used sdb1 before but the device is mounted on sda1 now

I tried again.. the result is the same. chmod -R 777 /mnt/sda1 is executing but nothing changes in the permissions.

Does /mnt/sda1 even exist? as the device is mounted to sda1

ls -l /mnt/sda1

You might need to create this directory, then apply the permissions

I may have mistyped that line. Whenever usb is removed from router the mount point differs between sda1 and sda2 or vice-versa... I created directory mkdir then applied permissions... chmod -R 777 /mnt/sda1 or sdb2/dir_name...

suppose dir name hello1
mkdir hello1
before chmod
drwxr-xr-x 2 root root 4096 Feb 26 10:59 hello1

after chmod
chmod -R 777 hello1
drwxr-xr-x 2 root root 4096 Feb 26 10:59 hello1

nothing changes...

You need to determine your mount point directory e.g. /mnt/sda1 or /mnt/sdb1 or /mnt/sdxx

Importanty! the directory(s) have to exist prior to any USB drive mount.

cat /proc/mounts will advise you of the mount directory...
e.g. this output /dev/sdb1 /mnt/sda1 exfat tells you it's mounted to /mnt/sda1

confim the directory exists, in the above case
ls -l /mnt/sda1
then apply the chmod commands to the proper mount point directory, in the above case
chmod -R 777 /mnt/sda1

Apart from this I'm out of ideas.

root@OpenWrt:/mnt/sda1# cat /proc/mounts
/dev/root /rom squashfs ro,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,noatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,noatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,noatime 0 0
/dev/mtdblock6 /overlay jffs2 rw,noatime 0 0
overlayfs:/overlay / overlay rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,size=512k,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,mode=600,ptmxmode=000 0 0
debugfs /sys/kernel/debug debugfs rw,noatime 0 0
/dev/sda1 /mnt/sda1 exfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,namecase=0,errors=remount-ro 0 0

Thanks a lot for helping out... I will give this a rest for a while then get back to it.

If I remember correctly, the mount points are removed on every reboot, only /mnt is persistent.

If you' like to have 777, you have to manually create the /mnt/mountpoint and afterwards do a
chmod on it.

It can be added to the local startup script in System->Startup->Local Startup.

uci set fstab.@mount[-1].options="umask=0"
uci commit fstab
block umount
block mount
2 Likes

Aaaaand , there it was.

I didn't feel like digging to deep into the issue, when I had it.
Quick and dirty worked, at that time :wink:

Thanks a lot guys... i think i fixed it somehow... i don't know what i did but the permissions are set now.

drwxrwxrwx 9 root root 4096 Jan 1 1970 sda1
I can access it using my created user/password with full RW permissions.
I think i may've messed around with mounting points. Don't know exactly what fixed it.


This is my luci page and everything works

config samba                                                                           
        option name 'OpenWrt'                                                          
        option workgroup 'WORKGROUP'                                                   
        option description 'OpenWrt'                                                   
        option homes '0'                                                               
                                                                                       
config sambashare                                                                      
        option browseable 'yes'                                                        
        option name 'saharename'                                                       
        option path '/share'                                                           
        option read_only 'no'                                                          
        option guest_ok 'yes'                                                          
        option create_mask '777'                                                       
        option dir_mask '777'
[global]                                                                               
        netbios name = OpenWrt                                                         
        display charset = UTF-8                                                        
        interfaces = lo br-lan                                                         
        server string = OpenWrt                                                        
        unix charset = UTF-8                                                           
        workgroup = WORKGROUP                                                          
        bind interfaces only = yes                                                     
        deadtime = 30                                                                  
        enable core files = no                                                         
        invalid users = root                                                           
        local master = no                                                              
        map to guest = Bad User                                                        
        max protocol = SMB2                                                            
        min receivefile size = 16384                                                   
        null passwords = yes                                                           
        passdb backend = smbpasswd                                                     
        security = user                                                                
        smb passwd file = /etc/samba/smbpasswd                                         
        use sendfile = yes                                                             
                                                                                       
[saharename]                                                                           
        path = /share                                                                  
        read only = no                                                                 
        guest ok = yes                                                                 
        create mask = 777                                                              
        directory mask = 777                                                           
        browseable = yes

Thanks... I think the issue has been resolved (i think so) by using the root user for samba login on clients. Also about the permission not changing, it's due to my fat32 formatting, it's behavior is quite normal on linux platform. I think i am fine with current settings as they are. It would've been easy if i could just format it into ext2/3 but unfortunately i can't due to many reasons.

This typically depends on the mount options, so specifying umask=0 should help.

They are already set.

Anyway i am fine with it as long as it works...

1 Like

In template file

/etc/samba/smb.conf.template

add one line at the end

force user = root

This will violate all Linux security principles, so use it on your own risk :slight_smile: But if you are in a controlled environment where you manage in some other way who is accessing your network, this a solution until you find something smarter. At least do not allow samba access over the wan port.

Good luck!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.