Score:0

Samba file lock prevents media unmount

pk flag

I have a small server with a samba share that sometimes I use to share removable disks connected in the hot swap bays. After mounting a disk and accessing it, I try to unmount it, but umount refuses (even using -f) to do it because the disk is busy: umount: /share/external: target is busy..

lsof reports:

smbd      62850                                root  cwd       DIR               8,65       4096          1 /share/external
smbd      62850                                root   46r      DIR               8,65       4096          1 /share/external
smbd      62851                          alessandro  cwd       DIR               8,65       4096          1 /share/external

smbstatus shows the mountpoint is locked (I already closed the file manager):

Locked files:
Pid          User(ID)   DenyMode   Access      R/W        Oplock           SharePath   Name   Time
---------------------------------------------
62850        1000       DENY_NONE  0x81        RDONLY     NONE             /share/external   .   Mon Mar 14 17:09:58 2022

So, to unmount the drive I have to restart smbd first and then I can run umount successfully, but I want to avoid restarting the service, or killing processes manually (as I saw searching online). I also tried to disable possible locks in smb.conf with

        locking = No
        oplocks = No

but without success.

Does someone know how to stop this behavior and allow unmounting without restarting?

Useful information:
  • Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-104-generic x86_64)
  • Samba version 4.13.17-Ubuntu
cn flag
Could you explain what is `smbclose` for a program?
djdomi avatar
za flag
have you tried `smbclose /share/external` ?
Alessandro Campolo avatar
pk flag
@djdomi just done but no luck `smbclose: command not found` I tried googling the command but found nothing.
djdomi avatar
za flag
i use apt-file if a command is not working
Alessandro Campolo avatar
pk flag
@djdomi I tried `apt-file search smbclose` and `apt-file list smbclose` but still nothing, are you sure smbclose is included in samba from repository and is not from a custom compiled version of it?
djdomi avatar
za flag
well the other way would to kill the PID.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.