SMB Server In Docker with ZFS! Simple, Cheap, and Efficient!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody and welcome back to Jim's Garage in this video I'm going to show you how to use your existing proxmox setup to create the ultimate cheap barebones Nets that's right we can use the existing proxmox setup to create a ZFS raid that we can pass through to a virtual machine and spin up a lightweight container creating a samb share now to get this up and running it's going to be pretty minimalist and you might even have the requirements already in this instance I'm going to get two additional drop knes don't buy these they're terrible and I'm going to set up a ZFS raid within proxmox and then going to assign this as a volume within a virtual machine and then install Docker so that we can deploy a container and reference that storage space that's great because under the hood we know that we've got ZFS raid backing up all of our data and you can extrapolate this as far as you want you could add more discs and create more redundant arrays just choose something that you can afford and fit within your machine now why might you want to do this well I'm a big fan of tras I think it's excellent and I'm not going to be changing it anytime soon but that's because I'm fortunate and I have some dedicated Hardware that I can set aside to do that but if you don't have that or you simply don't require it it has a few benefits firstly you're not going to need an extra machine you can use the machine you already have secondly if you've been following my videos I've showed you how to do a virtualized tras but again that requires additional Hardware with an HBA this it doesn't require that we're going to create the ZFS on proxmox and then we're going to pass that through to a virtual machine so to demonstrate this I'm going to be using my Dell r730 simply because it has a number of SSD slots that can accommodate this and because it supports hop swapping which makes making this video easier but the process for getting this up and running on something less Enterprise is pretty much the same and you have seen me do this in my Naas build before essentially you're going to need to plug these into your SATA connections on your machine and then we're going to select those and create a ZFS raid from them and the steps I'm going to detail should be applicable so I'm going to show you what my proxmox storage looks like now and then going to install these drives into the machine and hopefully those will be picked up in proxmox and we can begin the ZFS raid process so here over in proxmox you can see my existing storage within my Dell server you can see that I've got the quad nvme which I've discussed before which is my super fast storage for all of my virtual machines and then I've got SDA and SDA which are my ssds where I have proxmox installed so I have a mirrored raid for my proxmox installation just in case that boot drive went down I've now transferred these to their caddies for my Dell and I'm going to insert them into the machine and fingers crossed they're automatically p pick top if they're not and this might be more typical on consumer equipment you'll simply need to reboot your device and they should be listed here so fingers crossed here we go so now with any look we should be able to hit reload and see those new drives let's give that a whirl so reload yeah there we go we've got SDC and we've got SD now those have already got some data on so they're going to be wiped during the ZFS process just just bear that in mind don't use any diss that you got data that you care about so how do we create the ZFS so in my instance before we get started I'm going to wipe this disc so SDC I'm going to hit wipe dis and click yes and then I'm going to repeat the process for SD so that's here wipe this dis and hit yes now that our discs are wiped we can create the ZFS itself so to do that on screen already you might see ZFS so we want to create a new one and you'll probably see a couple here already the rpool being the one that my prox MOX is installed to and the mvme being my quad nvme ZFS pool so if we hit create ZFS it's going to list the two drives that aren't used by any existing pools so I'm going to give this Naz as its name and I'm going to select the drives that I have here now I can't choose raids because I don't have three diss remember there's redundancy here but if you have three discs you can obviously benefit from that so to kind of cheat with my setup in two discs I'm just going to choose a mirror but I do recommend raids because it's going to give you redundancy and the ability to expand this in the future so moving over to the bottom right I'm going to hit create and now that's created our mirrored raid pool so so now that we've got that we can actually begin to use it and in data center we can see that we've got Nas up the top and it's set to allow disk images and containers which is what we want because that's going to allow us to specify this in the VM if you wanted to you could edit this and reduce those two options or if you wanted to add more to it you'd need to add a subdirectory assigned to the CFS with the relevant path specified similar to how I've got here Mount PV traz and mount PV nvma Asus and once you've done that you'd be able to add things like your backup files your dumps Etc so now that we've got the NZ available as a data we can head over to this VM I've created and this is just a virtual machine created using my cloud in it you can go and find out how to do that but it makes creating virtual machines really simple so on the hardware tab now you can see that by default it's created a hard disk with 10 gigs of space but we now want to add our new drive so hitting add and then hitting hard disk you can see that we can assign it I'm just going to leave that as scuzzy one CU scuzzy Z is already taken by the boot drive and then we can see here storage so I'm going to click Nas and yeah fine 32 gigs works for me you could obviously give it more space now I'm going to turn on the discard for this one because it's an SSD and I'm also going to do the SSD emulation so that now means that it's going to reclaim some space as and when required and then I'm going to click add so now we've got this secondary hard disk here and we know that under the hood anything that gets written to this drive is actually mirrored with ZFS and we can add additional drives in my case that's just going to keep creating the new mirror but if you've got something like a rage one or a Rage 2 again there are a minimum number of drives you will need for each of those a raage one's is going to mean that one of those drives can fail and you're okay A Rage two two drives rage three three you get the idea but now importantly we can start this machine up I'm going to let the cloud init process finish but once this process is finished we're going to verify that we've got the volume we assigned to it installed and then fingers cross we should be able to install Docker and start using it for our container mounts so I'm going to let this run and I'll see you on the other side and so now that installation process has finished and just a reminder this is using a cloud image which behaves a little bit differently to the default abunto installation or whichever flavor of guided wizard you'll be using for a desktop or server image but once that's completed and I run an lsblk to list the storage devices you can see here at the bottom the SBD I've got here 32 gigs which is that dis we've got SDA which is the original 10 gig and then this one here which is now backed up by our as or in this case our proxmox ZFS pool so now that we've got the infrastructure sorted let's hop into how we're going to do this in terms of Docker so whilst we discuss that in the background I'm just going to make sure that docker's on here but if you've been following my videos you should already have Docker installed Additionally you could take your existing virtual machine so for example over here I have my Docker VM this is 111 I could go to the hardware Tab and then I could shut this machine down and then I could click add a hard disk and then again I could select that Nas and then assign some storage to that then on the next boot up I'd need to mount that and make sure that it's usable as storage space so now I've installed Docker and good old painer we're in a position to start using our newly added drive but there's a few things we need to do first most likely you're going to need to format this drive before you can use it then you're going to need to create a position where you want this to be mounted to and then finally you're going to mount it to that position or folder in this case so let's go now and format our new Drive first otherwise we can't use it so to do that I'm going to format this dis by make file system extension 4 and then I'm going to do/ device and then sdb which if you remember back to when I run the lsblk command we know that the device we've added has come up as sdb so hit and return on that everything looks fine it's gone away and formatted it the next thing we need to do is to do a pseudo makeer and then slash I'm going to call this one SMB so when I create this folder it's going to put that in the root directory and then once I've done that I can do a pseudo Mount and then I want /dev SL sdb and then the location I want is SLS SMB so now when I hit return that should have mounted those drives to that folder location great now that we've got that we can jump into the Container so as always on my channel I'm going to give you an overview of the container itself so the docker compos I'm going to show you some of the variables and what I've got them set to we're also going to look at the config file because that's going to be important for our sambare because that's where we set up all of the users and the permissions related to this so what's really cool is although we've created a/ SM SMB folder you could share the entire root of that folder if you wanted to or you can create any type of subdirectories and folder permissions that are accredited to each one of those so you could have multiple users all assigned access to different folders this can also be done with NFS and I'll link a container in the bottom that you can do this with do bear in mind that you don't have to use Docker for this you could just install a bar VM or an lxc and install the samb server itself and the process will be pretty similar but I prefer the Simplicity and the repeatability that comes with Docker and the fact that you can just run a single composed file and have all of this up and running so over in vs code let's have a quick look at the compos file so I'm using the image by crazy Max thank you and I've had a quick look at this and it uses the latest version of Samba with all of the security fixes applied and all of the latest features so go ahead and give it a name I'm going to leave it as samb and then importantly we get on to the volumes so this first volume here this slash data folder this is where the cache configurations and runtime data are so this isn't a mount location for your data now change this to wherever you want it to be if you leave it with a slash it's going to put it in the same folder as your composed file and then the SLP public is the bit that we want to change now this is your actual samb share so here I'm going to change this to if you're remember I changed it to slmb so now that slmb folder on my host is going to get mapped to this public sambare within the container great remember as I said previously if you have lots of different shares that you want to be sharing you would simply add more now I've left in some examp course here from the example compos file so that you get an idea of what that might look like you simply need to map these on the left to wherever they reside on the host and then on the right hand side you would need to give it some name we'll come on to that in a moment because as I said before there is a config file here so things like share Fu fuas whatever you'd have real names of course those are all mapped out in here but let's finish the composed file first so it takes a number of environment variables and I've only specified two in my example but do know all of the ones that are commented out you could tweak if you wanted to if you've got a more exotic setup or you want to try and restrict this in some way so all I've set is the time zone to Europe and the log level to zero you can obviously increase that if you want more verbosity in your logging now of the ones that are commented out there probably aren't too many that you want to change by default it's going to use the work group name for the SMB share and I recommend keeping that is cu that's the default you may also want to give it a server string if that's something that's helpful for you the other thing that's important is perhaps the samb hosts allow so by default it's going to allow anyone but if you only wanted to accept connections from certain hosts a little bit like a firewall you could specify the specific IP addresses or the IP arrangers that you care for so by default it's going to accept anything local on your Lan but if you want to restrict that to just a subnet or a given machine go ahead and do that by default it's going to listen to All interfaces and then there's a number of settings that you can put here whether it does WS dd2 Now by default that's not set and there's no string assigned to that but you can assign those if you wanted to I've set this to restart always because if it's a NZ we're probably going to expect this to be on 24/7 so now we've gone over the compose which is pretty straightforward let's have a look at the config because as I mentioned the config is important because this is where we can set the people and the share volumes now looking through here I'm going to go with the following setup with just a couple of tweaks now you can tweak this to whatever you need and however many users you want or however many directories you need but let's have a look what's going on here so at the top we've created a user of Foo in the group Fu with an ID of 1,000 which is what my current user is within my Docker environment and I've set a password of bar now you could have another user for example in the documentation they use baz this person will have a different user ID and potentially a different group ID which then would give them different permissions on the share if you want to set that up now the global settings are to force the user of Fu and then in this instance which creating one share now this share is called the public which if we go back to the docker compose you can see we Mount here now because this is a public it comes with some defaults so the path is/ sambu which is what we've specified in the compos file we've said that it's browsable which makes sense if it's public and it's readon yes now I'm actually going to change that to no just because I want to demonstrate writing to this but in your instance you may want to go and create another share down here which is as you can see the example of readon no and that is going to be assigned to somebody like baz for example and now hopefully this will give us the ability to demonstrate reading and writing to and from this directory so now that we've got this set up and you understand how to create new users and specify new shares and have all of those options within those shares let's copy it over and let's get this container up and running as a little sneak peek I am going to show you how to copy these files over and launch containers within vs code so watch out for that and so now that we've done that you can see on this machine here which is this one in the background I've created an SMB folder I've put the docker composed file in there and I've created the subdirectory for data with the config file in which is what's expected as the default in here you can obviously change that to whatever location you want and now we're in a position where we can start this container so let's get on with it so now I'm in the right folder I'm going to do a pseudo Docker compose up- D and with any look this container should start and it should start serving that SMB share so it's pulling down that container and then very shortly we'll be able to test if this is up and running I'm going to jump into pora and just check the logs just in case so over on my new instance of Pena I'm going to go into the logs and let's have a look what's going on so we can see that the container started successfully it's added those users it's used the config file we specified and then it spat out all of the configuration that we had that all looks good and if we scroll down the hosts allow looks good you can see those default values the public share looks okay everything's done the service is starting great and you can see that we're on version 4.89 which I believe is the latest version so fingers crossed we should now be able to go into Windows for example and mount this as a share location let's go and do that now so in Windows if we right click this PC and then we click map and network drive we get some options to do that so you can choose a drive letter to use I'm just going to use y because that's available on my machine and then we're going to need to do a SL slash the IP address in this case it's 192 168 20000 183 I recommend you make this a static IP for obvious reasons and you can even use a DNS name if you wanted to and then I'm going to do a slash and we need the share name so if you remember I think we called this one public so we'll call this one public and then we're going to need to use different credentials for this because by default it's going to use your windows credentials so hitting finish it's asked us for what it is and I believe it was Foo for the user and bar for the password you probably want to remember your credentials so that you don't have to type this in every time and it should also mean that it will automatically reconnect to this drive every time you start your machine so hitting okay Bingo we've got our share and it really is that simple so now we have an SMB share running in Docker that the underlying Hardware is on a ZFS raid and we haven't had to spin up a new virtual machine in terms of something like traz and we haven't got the overheads of additional Hardware I.E a whole new machine and all of the Power costs that come with it and with ZFS raid you can add new drives and New Pools vdevs Etc and expand this as far as you need to now testing this out you might run into the following problem so if we go new and then we say a text document uh oh we don't have access our permission here was denied so what can we do well it's probably because if we check the folder permission here and we hit properties we can see that it's probably set up something like this where other users don't have the ability to write or execute so if we hop into the terminal we can change these permissions to match whatever we want now I'm going to give you the overlaying just give me everything which would be 777 I recommend you tweak this to whatever users you want and their respective permissions and the respective subdirectory as well but just to demonstrate this if we set it to 777 so now everybody's got permission to do anything to this folder if we head back now we can right click and we should be able to hit new and then a text document and there you go we've created it and that's in there and then if we want to create something in here I'm just going to put the text of test and now if I save that hopefully if we now go back into our terminal we do a cd/ SM SMB we do an LS we've got that new text document and if we Nano that new text document we can see that we've got test inside excellent and if we want to test that we can do something else we can save that and then hopefully if we open that up again in Windows we'll see that we've now got that new text so brilliant everything seems to be working across Linux and windows and we've got that share mounted so now you have all of the tools you need to create a Bare Bones Nas on your existing Hardware obviously that comes with all the benefits of you pretty much have everything you need already and it's going to be super minimalist now obviously you can run this as just a sambare on proxmox I don't really like that approach because I want proxmox to do what it does best that's hosting VMS and anything else on top of that is going to add additional complexity possibly break things and cause more of a nightmare to actually solve the issues I'm not saying don't go and do that I'm just saying I don't want to take that risk you could also do this through an lxc if you wanted to and that's really lightweight but I prefer to use my existing Docker setup because I have that and I love the repeatability of Docker compose so let me know if this is something that you're going to do in the future and I might come on to NFS if you need a tutorial for that but for now I'm going to wrap it up here so if you've enjoyed this please give it a thumbs up hit that subscribe button and I'll see you all soon take care [Music] everybody h
Info
Channel: Jim's Garage
Views: 30,325
Rating: undefined out of 5
Keywords: NAS, cheap NAS, build a cheap NAS, cheap homelab, cheap server, proxmox, linux, truenas, SMB share, NFS, docker, portainer, best NAS, zfs explained, zfs unraid, proxmox tutorial, proxmox setup, proxmox nas, homelab, docker tutorial, docker tutorial for beginners, docker compose, homelab setup, homelab server
Id: Yw8QMrTHCw4
Channel Id: undefined
Length: 22min 59sec (1379 seconds)
Published: Sat Jan 20 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.