0

I have a USB drive shared from a Raspberry Pi via Samba.

Everything works fine, but when I disconnect the USB drive, the mounting folder (/media/usb1) still exists and its still being shared through Samba as an empty folder.

What I would have expected is Samba to stop sharing that resource, and appear as disconnected or unavailable in Windows, as its mapped as a network drive.

Is there a way to tell Samba to stop sharing the resource if it's empty? Is there any other workaround?

My smb.conf entry for this shared resource is the following:

[usbdrive]
path = /media/usb1
browseable = yes
writeable = yes
only guest = no
create mask = 0777
directory mask = 0777
public = no
4
  • Did you unmount the USB before disconnecting?
    – harrymc
    Commented Aug 12, 2022 at 20:08
  • 1
    I would suggest sharing a sub-folder on the USB media so that when you umount, it no longer exists. How is samba supposed to know that it was for a removable device? The folder is still there and still accessible. Unix's stupidity is also it's strength. Most things aren't overthought or over programmed. It the organization of things by the user that make it powerful. Commented Aug 12, 2022 at 20:51
  • @harrymc No I did not unmount the USB, but I have rebooted the machine and it's still showing. Commented Aug 12, 2022 at 21:11
  • @SeñorCMasMas correct, it's doing what's logical, but not what I want :) The subfolder workaround sounds like a great idea to me. Can you post it as an answer? Commented Aug 12, 2022 at 21:12

1 Answer 1

2

I would suggest sharing a sub-folder on the USB media so that when you umount, it no longer exists.

To be honest, I myself have been in your exact shoes.

Samba doesn't know that it was for a removable device as the folder is still there and still accessible.

Unix's stupidity is also it's strength. Most things aren't overthought or over programmed. It is the organization of things by the user that make it powerful.

4
  • Oh.. one other thing. If you "pull the plug" on stuff samba is working with. Sometimes bad things can happen. This is far worse when using a samba-client against a windows server but bad stuff can happen the other way around too. Commented Aug 12, 2022 at 21:17
  • Yeah, I literally pulled the plug, then when I saw it still appeared in Samba I tried to unmount it and said it couldn't because it was busy... oops... I have not plugged it since, wish me good luck and not have the stupidity to do it again :) Commented Aug 12, 2022 at 21:21
  • If it works. Please mark me as the answer you want. If it doesn't, down-vote me and comment (please). Good Luck! :) Commented Aug 12, 2022 at 21:25
  • Sure, I already upvoted it, I am just waiting to see if any other answers pops in, if it doesn't I will accept you answer. Thanks! Commented Aug 12, 2022 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .