Samba: The process cannot access the file because another process has locked a portion of the file

Samba: The process cannot access the file because another process has locked a portion of the file

Tags :

Category : How-to

Get Social!

Copy file error on samba share over nfsI had a problem with a SMB share which was sharing storage from an NFS mount.

Whilst you could argue that it is not efficient to share storage this way, sometimes there is a valid need.

The error was displayed when creating a none empty file, or copying a non zero byte file to the storage. The error is displayed, in my case in Windows, in a dialogue box.

Error:

To fix this issue we need to open the smb.conf file on the Samba server

In the general section of the smb.conf (that is usually the part at the top of the file) add “strict locking = no“. An example of how your smb.conf file may look is below.

When strict locking is disabled, the NFS server will only lock the file when the client tells it to. When it is enabled, the NFS server locks the file on every read and write.


Related posts:


19 Comments

aGus

9-Sep-2013 at 3:36 am

Many Thanks to you James :)

franz

26-Sep-2013 at 6:51 am

saved my morning, thx

Stym

30-Jan-2014 at 1:55 pm

Right on spot. Thanks.

    james.coyle

    30-Jan-2014 at 1:59 pm

    I’m glad it helped!

      Ganesh

      11-Sep-2017 at 4:56 pm

      This worked Thanks James….

Erick Rivera

20-Feb-2014 at 5:59 pm

Excellent my friend, works fine.

Thanks

Aaron

16-Apr-2014 at 3:30 pm

Very helpful after migrating from an ancient samba server and no one could save work. Thanks!

goudeuk

25-Jun-2014 at 11:02 am

A big THANK YOU

Ingo ratsdorf

25-Aug-2014 at 2:58 am

Hmm, interesting. The documentation says that strict locking is off by default anyway…
So puzzled on whether this is correct or whether some OSes are implementing different defaults.
(ref http://oreilly.com/openbook/samba/book/ch05_05.html)

Peter Huang

29-Apr-2015 at 12:59 pm

>> When [strict locking] is enabled, the NFS server locks the file on every read and write.

From what I’ve read, “strict locking” means that each read/write will check whether a range is locked before performing the operation (or fail if the range is locked); not that the read/write itself actually locks a range. I guess it is effectively the same if each read/write is atomic (ie. reads from different clients can not occur at the same time). If however, two reads can occur at the same time (think two very large data reads), then a read that performs a lock (as opposed to just checking for a lock) could conceivable cause another simultaneous read to fail

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/locking.html

razali

22-Sep-2015 at 4:41 am

big thank, and my problem solved

Eduard

22-Oct-2015 at 5:18 pm

James

Almost 3 years on and still making lives easier. Thanks a million.

Ed

Alexandre Peloquin

5-May-2016 at 2:12 am

Worked like a charm! Thank you!

    james.coyle

    5-May-2016 at 2:17 am

    Great!

Alejandro

14-May-2016 at 8:46 pm

Thank you so much!

Dragos

17-Feb-2017 at 1:47 pm

Thank you too !!!

tu

12-Jul-2017 at 1:19 pm

Thank you very much for this solution.

Worked like a charm.

Fernando Mérito

9-Aug-2017 at 11:37 pm

Thank you so much! thanks for sharing

Zhibin

13-Feb-2018 at 3:25 pm

Can not thank you more. You saved me!

Leave a Reply

Visit our advertisers

Search

Quick Poll

Are you using Docker.io?

Visit our advertisers