Is this possible with SAMBA?

Hello everyone, I was wondering if it's possible to setup the SAMBA protocol in such a way that any storage device is connected to the SAMBA server is automagically shared onto the LAN. I don't this to work like hot plug but that at least if a drive is connected during the boot is mounted and shared once the server starts up. Thanks.

1 Like

I've never heard of anyone doing this but my guess would be that you would first have to setup the drives to be auto-mounted on the server and then write a shell script that looks for new drives and then adds a samba entry based on the information it finds. The shell script should be run on boot as well.

1 Like

Automount is already in place and it works (if I plug a drive when it's on I can browse it locally). This is a pretty good hint but I'm not that familiar with Linux so I don't know where to start to write a script like that. Also this should work on a Raspberry Pi 2, but I guess it doesen't matter that much (?). Thanks for the answer.

The easy dirty way would be to make the parrent directory a share; e.g. if you OS mounts drives automatically into /media/ you make media and its children a SMB share.

e.g. you have the share "media" under which you will find the mounted drives

3 Likes

So that would actually work? I didn't think that would work but I'm gonna try that as soon as I can, thank you a lot! While I'm at that and you have competence about this subject how could I access the drives mounted in the system also outside of my network?

well, there are many ways of doing that.. but that needs a lot more care to make that secure.
It's a huge topic, ranging from a VPN to owncloud like approach, sftp, https would also work.. but needs to be carefully crafted so not everyone can A) see you stuff B) mess with your stuff

1 Like

Yeah, that makes a lot of sense. VPN is out of question since I my internet speeds are terrible (10Mbit D and 0.55Mbit U). I was looking at something like OwnCloud that seems reasonable to set up, easy to manage and has built in security. What if I go that route?

to be honest with 0.55Mbit up, screw that idea. You will not be happy. Imagine a image that has 3MB... that’s ~ 6 minutes without protocol overhead.

Even loading the web UI of owncloud would feel terrible slow, and to make owncloud secure is yet another adventure XD

Well first of all I love to tinker with stuff and also I would use that do drop files from phone while I'm out so the upload speed wouldn't be that much of an issue anyway. If you have any guide that I can follow or you can give me directions on what to do that would be greatly appreciated! You're already helping me a lot.

Well as for getting owncloud running on a LAMP stack:
https://www.google.com/?gfe_rd=cr&ei=edL2VpqcA-ag8wf2hL74BA&gws_rd=ssl#q=owncloud+how+to

(A google search for owncloud how to ^^)

But owncloud will not offer you the shares like SMB does; it's its own kinda filesystem ... so you can't just say share the /media/ folder

1 Like

I wasn't asking for the Owncloud guide because I already had that on hand and would've been stupid lol I wanted to know if you wanted to guide me in what you think works best.

ah ok, misunderstood that.

  • well for your local needs, quick and dirty - as said sharing the folder that the drives get outomounted into.

  • for you wanting to access them over the internet, I am not shure how to accomplish that given you mediocre internet and the fact you want to upload to the dirves as well.
    I think, I would go for (s)ftp as that would allow you to do pretty much the same as with SMB, but I honestly have not been looking into wether there are (s)ftp clients for phones, that are good.

But if there are, I would setup proftpd and than have it /media/ as its / direcotry which also allows you to access all folders (mounted drives) in that directory.

1 Like

No problem mate, can happen. I'm gonna get my hands dirty on this and try to do everything. I may have a bad internet connection but this won't stop me from poking at IT stuff until something bites me in the ass hahaha Again thanks for all the help, it was much appreciated. Take care.

1 Like

I've stumbled upon a little problem: in this guide (http://pimylifeup.com/raspberry-pi-nas/) you need to create a new user and add to the fstab file the automount of the storage device for the user created specifically for it. What I should do if I don't want that? Just skip everything and go directly to the SAMBA config?

Yeah, should work if you just use your exciting (pi?) user instead.

You mean the existing user to access the SAMBA share?

The user they create in the tutorial is added to fstab so it's the owner of the mounted directory. aka can read/write to it.

As you do not wan't to create a new user, you'll have to use the user you are using (so much use) ... you will have to garant "yourusername" the rights to access the files and folders.

I lost you right now, I'm sorry.

Sorry!

They creat the user pimylifeup to later be used to access the SMB share(s). So when you follow the tutorial to the letter, you later will need the username pimylifeup + its password to access the SMB shares.

As you do not want to create any additional user, you have to use an excising one instead.
So when you go along with the tutorial, you need to use the user (username) that you have instead of the pimylifeup the tutorial uses.

Oh and check which groups your current username is in; the tutorial uses force group = users to garant access to the shares. So every user that wants access to the shares must be in that group.

So, if you use the default raspberrypi user pi its group is pi as well; I would add the username you like to utilize to the user group and stick with the tutorial otherwise.

1 Like

Perfect! Thanks for the further explaination. So I skip that, edit the config with pi for user and group and don't skip all toghether the fstab changes and the user add part right?