When managing a Linux server running Samba (particularly Debian Squeeze in this case), you might encounter stubborn .fuse_hidden*
files that regenerate instantly when deleted. These files typically appear when Windows clients access Samba shares and encounter file locking issues.
The .fuse_hiddenXXXXXX
files are created by FUSE (Filesystem in Userspace) when a file is being accessed but needs to appear deleted to other processes. This often occurs when:
- Windows clients hold file handles open
- Samba's oplocks (opportunistic locking) are active
- File operations are interrupted
Here are several approaches to resolve this issue:
1. Force Unmount and Clean
First identify the mounted share:
# mount | grep samba
//192.168.1.100/share on /mnt/share type cifs (rw,relatime)
Then force unmount:
# umount -l /mnt/share
Now you can safely delete the directory:
# rm -rf /mnt/share/problem_directory
2. Disable Oplocks in Samba Config
Edit your smb.conf:
# nano /etc/samba/smb.conf
Add these parameters to your share definition:
[problem_share]
oplocks = no
level2 oplocks = no
kernel oplocks = no
Restart Samba:
# service smbd restart
3. Use lsof to Find Processes
Identify processes holding files open:
# lsof | grep fuse_hidden
# lsof /path/to/problem_directory
Kill the offending processes (if safe to do so):
# kill -9 PID
4. Alternative Deletion Method
Try moving the directory first:
# mv problem_directory problem_directory.old
# rm -rf problem_directory.old
- Regularly audit open file handles with
lsof
- Consider implementing proper file locking protocols
- Monitor Samba logs for oplock conflicts
- Educate Windows users about proper file closing
Enable verbose logging in smb.conf:
[global]
log level = 3
debug hires timestamp = yes
Check Samba logs after reproduction:
# tail -f /var/log/samba/log.smbd
When working with Samba shares on Linux servers, you might encounter stubborn .fuse_hidden*
files that reappear after deletion. These files typically appear when:
- A Windows client fails to properly close a file handle
- Network interruptions occur during file operations
- Permission conflicts exist between Samba and local filesystem
The .fuse_hidden000XXXXX
files are created by FUSE (Filesystem in Userspace) when a process maintains an open file handle. Each hex number represents a unique file identifier. Simply deleting these files won't work because:
# This fails because the process still holds the file descriptor
rm -f .fuse_hidden000bd8c100000185
Method 1: Terminate the Owning Process
First identify the process holding the file handle:
lsof +D /path/to/problem/directory | grep fuse
Then gracefully terminate it:
kill -15 PID # Send SIGTERM
# If unresponsive:
kill -9 PID # Send SIGKILL
Method 2: Force Unmount and Remount
For persistent cases, unmount the share:
umount -l /mnt/share # Lazy unmount
# Then remount:
mount -a
Method 3: Samba-Specific Commands
Use Samba's diagnostic tools:
smbstatus -L # List locked files
smbcontrol smbd close-share SHARENAME # Force close
Add these to your /etc/samba/smb.conf
:
[global]
kernel oplocks = no
oplocks = no
strict locking = yes
For recurring issues, create a cleanup script:
#!/bin/bash
SHARE_PATH="/path/to/share"
# Find and kill processes holding fuse files
lsof +D "$SHARE_PATH" | grep 'fuse' | awk '{print $2}' | xargs kill -9
# Remove hidden files
find "$SHARE_PATH" -name '.fuse_hidden*' -exec rm -f {} +