I'm hosting a simple Apache web server on a Raspberry Pi running Debian, which so far only serves up static content out of its default /var/www/ directory.

I wanted to share the /var/www/ folder via Samba so I can easily mount the folder from a Windows machine and make quick updates directly on the server.

From a Windows machine (via the Samba share), I'm able to...

  • Read files of any filetype
  • Rename, create, or delete files of any filetype
  • Modify the contents of most filetypes

However, I am unable to modify .html and .htm files (perhaps other filetypes as well) from Windows and receive the following error message when trying to save a modification:

The process cannot access the file because it is being used by another process.

This happens regardless of which editor I use in Windows (e.g., Notepad, Visual Studio, etc).

From Windows, this gives me the interesting ability to rename an affected file (e.g., change it from *.htm to *.htm.edit), modify the contents, and then change the name back. But I cannot edit it without renaming.

I am still able to modify all files perfectly fine from Unix.

The owning user and file permissions are identical across both affected and unaffected files: -rwxrw-rw-

Note that other static web content that has been served up by the Apache server (e.g., CSS files) are still editable via Samba from the Windows client.

Since it seems limited to HTML-related files (thus far), my naive best guess is that it's some conflict between Samba and Apache, perhaps related to file locking. I tried disabling OpLocks for this Samba share (I'm not too familiar with them, but I've heard they can result in some locking woes) with no success.

The following is the portion of Samba configuration (smb.conf) file relevant to this Samba share:

Comment = WWW root folder
Path = /var/www
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
valid users = pi
force user = pi
strict locking = no
oplocks = False
level2 oplocks = False

I simply want the ability to edit .html files from a Windows client using the Samba share. Any advice into how I might troubleshoot or resolve this issue would be appreciated.

  • It states: " the file because it is being used by another process." If the Apache server is running, that locks the files. – DrMoishe Pippik Jan 1 '19 at 2:04

My issue was actually a lock conflict within Windows that seems to manifest only on a Samba share.

I discovered that for certain files (including HTML files), the preview handler used by the Windows Explorer preview pane obtains a Samba DENY_WRITE file lock, so having the file selected in Windows Explorer would lock it from being edited.

That surprises me: for an HTML file on the local Windows machine, the file lock obtained by the preview handler does not prevent other processes from writing it; but when the file is on a Samba share, for some reason that Windows file lock is translated into a DENY_WRITE lock in Samba so when the second process from the Windows machine (a text editor) tries to modify the file, it respects the Samba lock and naturally fails.

I don't personally need the preview handlers in Windows, so I simply disabled them (Folder Options >> 'View' Tab >> Uncheck 'Show preview handlers in preview pane'). This is more of a workaround; ideally, the preview handler's file lock wouldn't be translated into a DENY_WRITE lock in Samba.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.