Cant open file for writing with cifs mount

7,936

You could try the nodfs parameter (if supported) as explained in the article
How to workaround the DFS samba bug on the DNS323 NAS ? :

Firstly, here is a quick bug description: It's impossible to modify any existing files. The "Not a directory" or "No such file or directory" or "touch: setting times of…" errors occurs when trying to modify a file.

If your linux cifs or smbfs client support the nodfs flag (integrated in kernels > 2.6.27). You just have to add this option to the mount command. Example:

mount -t cifs -o credentials=/home/kerphi/.smb-zekra-credentials,iocharset=utf8,file_mode=0777,dir_mode=0777,nodfs //zekra/Volume_1 /home/kerphi/zekra

If you cannot upgrade your kernel (like me because i'm following the debian releases), you have to follow this workaround:

  • Connect to the DNS323 using the web GUI and goto tools→system.
  • Save the configuration to your workstation (in "CONFIGURATION SETTINGS" section).
  • After saving edit the file and just under this line:
    ;[ global ]
    add the following line:
    msdfs root = no
    Then upload this file through the web interface, your NAS will reboot and you will be able to modify existing file again !

This is further explained in CIFS: Add nodfs mount option :

Older samba server (eg. 3.0.24 from Debian etch) don't work correctly, if DFS paths are used. Such server claim that they support DFS, but fail to process some requests with DFS paths. Starting with Linux 2.6.26, the cifs clients starts sending DFS paths in such situations, rendering it unuseable with older samba servers.

The nodfs mount options forces a share to be used with non DFS paths, even if the server claims, that it supports it.

Share:
7,936

Related videos on Youtube

Aly
Author by

Aly

SOreadytohelp

Updated on September 18, 2022

Comments

  • Aly
    Aly over 1 year

    Hi I have mounted my QNAP on to a drive on my ubuntu machine using the following fstab entry

    //<ip-address>/Documents/Aly /home/aly/Documents cifs credentials=/root/.credentials,uid=1000,gid=1000,rw,hard,dir_mode=0777,file_mode=0777 0 0
    

    this gives the following permisssions:

    drwxrwxrwx  1 aly aly    0 2011-12-03 12:18 .
    drwxr-xr-x 13 aly aly 4096 2011-12-03 12:14 ..
    -rwxrwxrwx  1 aly aly    5 2011-12-03 11:55 test.tst
    drwxrwxrwx  1 aly aly    0 2011-11-26 17:54 VirtualBox VMs
    

    I have permissions to delete files and add files, however when trying to write to a file i.e. test.tst I get the following error in vi:

    "test.tst" E212: Can't open file for writing
    

    Has anyone seen this before, if i mount the drive via nfs this is not an issue, however nfs lacks the security i desire.

    EDIT

    The solution I have come to is:

    <ip-address>:Documents/Aly/ /home/aly/Documents cifs hard,noperm,nouid,credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777,nodfs 0 0
    
  • Aly
    Aly over 12 years
    No luck with this approach either :(
  • harrymc
    harrymc over 12 years
    What is your take on these : link1 and link2.
  • Aly
    Aly over 12 years
    Hi Thanks I seem to have it working - will edit my question with the solution and mark yours as correct as it provided me with all the info. A well deserved bounty!