Skip to main content

Samba Network Shares | Homelab Basics

Homelab Basics - Samba Network Shares



Hello there! Today I will be explaining what a Samba network share is, why you need one, and how to set it up. You will only need your server, and for this tutorial I will be using Ubuntu 18.04 Server LTS as my operating system, under my DL360 G6 running vSphere.

Requirements
-1 Core 500mhz+ Processor, 1ghz preferred
-256mb RAM, 1gb+ preferred
-Hard Drive/SSD to use as share
-Internal Network Connection, Ethernet preferred

What is a Samba Network Share, and why would you need one?
A samba network share is a filesystem that runs on your network, that is always connected to your network. Filesystems connected to your network are referred to as NAS' and are the backbone to both a business and home network. NAS' allow the user to store files not locally on their computer, but on a server's storage space. This helps conserve storage on the user's computer and allows easy file transfers between different user's computers.

Samba in particular uses the SMB/CIFS protocal for transferring files, and can be interfaced through (almost) all operating systems. This allows Samba to be very flexible in the transfer of files from Windows to Linux to MAC to Windows again. 

How to set it up?
As stated above, for this install we will be using Ubuntu 18.04.1 LTS as our OS of choice. Simply download it from the link, and burn it to a USB drive using Rufus (Rufus is my preferred burning method, you can use whatever burner you want).

After you have installed ubuntu and followed the login directions, update your computer's packages and security updates. This should always be done on a fresh install

sudo apt-get update && sudo apt upgrade && sudo reboot

After done updating, check if samba is installed.

whereis samba

This checks to see if samba is installed. If samba is not installed, run the following command

sudo apt install samba && sudo apt update

After this is done, you need to make user's named based on permissions. For this example we will use the usernames "family", "plex", and "guest". Run the following commands to add your users, changing them as you see fit (if you dont want the names to be family plex and guest.)

sudo adduser family && sudo adduser plex && sudo adduser guest

You will need to create new password for the users when prompted with "Enter new UNIX password". Simply create new password and you are off to the races! Press enter to accept the defaults when prompted with 

Full Name []
Room Number []
Work Phone []
Home Phone []
Other []

Enter Y or press enter to confirm defaults to continue. Now you will need to do the same on Samba. The passwords will need to be the same as the corresponding user's passwords. 

sudo smbpasswd -a family

After you have run the first command, hit the up arrow to retype the previous command and just modify it from there. The sudo smbpasswd command adds a user to samba and configures the passwd. We will have to run this command for all users, so 

sudo smbpasswd -a plex
sudo smbpasswd -a guest

Be sure that the passwords entered are EXACTLY the same as the ones used for the users. Now you need to make the directories you will be sharing. run the following commands to create sample directories for your users. Modify the commands as you see fit, as this command is not a one size fits all one. You will need to make sure that your folders are named the way you want them to. The things you should change will be in blue, not red

cd && sudo mkdir /Everybody && sudo mkdir /Everybody/Media && sudo mkdir /Family && sudo mkdir /Family/Documents && sudo mkdir /Plex && sudo mkdir /Plex/Media

You can rename directories at a later date by using 

sudo mv OldDirectoryName NewDirectoryName

Now you need to assign permissions to the folders

sudo chmod 777 /Everybody && sudo chmod 777 /Everybody/Media && sudo chmod 777 /Family && sudo chmod 777 /Family/Documents && sudo chmod 777 /Plex && sudo chmod 777 /Plex/Media

This will enable all of the users with physical access to the Samba shared folders. This is important because it will allow Samba to access the folders and make changes when necessary.Now that users, passwords, folders, and permissions have been setup, its time to modify the config files in samba. To do this, we will modify the existing samba config file.

Configure The Share
To configure the config file of samba, we will need to edit the samba.conf file. To do this, we will run the following command

Edit: People of reddit have brought to my attention that Vi is not the most user friendly text editor. I agree with this sentiment, and have adjusted the guide to use nano instead of vi. You can use any text editor that you want, but Nano is recommended for beginners. It all goes to personal preference though.

sudo nano /etc/samba/smb.conf

Arrow down to the "Workgroup" area. Verify that it is the same as your window's computer workgroups. You can confirm what the name is by going to
Control Panel -> System and Security -> System and looking at the "workgroup" area.

After you have confirmed the workgroup selection coincides with your windows computer's workgroup, scroll down to the very end of the file. You will need to enter this text at the very end of smb.conf. Remember that case matters in folder names. The text should change color and look similar to how it does here. If it does not change colour, you have entered it incorrectly.

[Everybody]
 path = /Everybody
 browseable = yes
 read only = no
 valid user = family plex guest

[Family]
 path = /Family
 browseable = no
 read only = no
 valid user = family plex

[Plex]
 path = /Plex
 browseable = no
 read only = no
 valid user = plex

Explanation
The brackets name doesnt matter, as it just names it in the confige file for easy access if you have multiple shares.

Path is the path in your linux server where the files will be located. It is important that you get this part right.

Browseable shows whether or not you will be able to browse the files using windows file explorer without having the credentials to the users specified in valid user. Basically, make this no for all private folders, and yes for all public folders.

Read only denotes if the users specified can write to the file foler, ie; make changes

Valid User denotes the users that can log on to see the folders and sub folders.

After you have made the necessary changes, press escape to get out of write mode, and hit ctrl +x to exit. Then follow the prompts answering y to the prompt to save changes to the config file. You will need to test the file to make sure that it will work in your share, so do

testparm /etc/samba/smb.conf

This tests for any errors. If you followed the typing exactly no errors should popup. After you have finished this, congratulations! You have a new file server setup using samba. Do

sudo reboot

to reboot the system and let it go! To see if it is successfully configured, go to your ubuntu server's ip address in the file folder using //192.168.1.6 (use whatever IP was assigned either by you or by the DHCP. You can check this by typing ifconfig in your linux terminal.) It will prompt for login information, so just login using one of the users you created and off you go! You should be able to store files in your new local file server.

Thanks for reading as always, if I made any errors then yell at me in the reddit comments and I will be more than happy to change the guide.  I made this guide because setting up a file server was one of the first things that I wanted to do with my server, and it was quite difficult the first time I did it. It gets very easy every time you do it after the first time though. This guide took me ~10 minutes to configure/setup the system, and around an hour to type it up.

Comments

  1. Hi Lohannes,

    I want to start my own Homelab. One of the first project will be to create proper backups.
    ATM I just copy files to a second drive.
    In addition I would like to automatically backup Android devices in the homenetwork.

    Do you think 'Samba Network Shares' is the right start for this project or should I look into something else?

    Best Regards
    Kolle

    ReplyDelete

Post a Comment

Popular posts from this blog

Running Doom on a TI-84/83 Calculator - A Guide

Running Doom on a TI-84/83 Calculator Hello there! Today I am writing this post as an exploration into the unknown: running a video game on a computer that hasn't been updated in the last 10 years. Of course, we cant run Crysis at the highest settings, but we can fortunately run doom pretty easily. Requirements -TI-84/83 Calculator -15 Minutes -A Micro USB Type B Connector - Ti Connect Why? You might be wondering "Lohannes, why wouldnt you just emulate this on a RPi Zero W" or "Why would you even?" To that I say, why not? I already dropped $120 on the biggest scam since printers existed so why wouldn't I try to get my money's worth? How? This is the fun part. First, you will need to connect your shiny new calculator from 2004 to your computer using the included USB Mini Type-B connector. After that, you will need to install the  TI Connect Software . This is what you will use to install programs and apps onto your calculator. Fo

Automatic Disk Ripping Machine Full Guide

Hello there! Today we will be focusing on one of my favorite things that I have built so far, my CD/DVD ripping machine! The official github page for this code can be found  here Requirements A CD/DVD Drive (obviously) A CPU with at least 2 cores At least 2gb ram A 60gb or more HDD/SSD Ubuntu 18.04 LTS ISO At least one hour of your time The Build I am rocking a way overkill i7-2600 and 12gb of DDR3 ram in this build. I did this partly because it was the only computer I had laying around, and partly because it speeds up the trans-coding process. I can rip CDs in 5-10 minutes each, and they are in my PleX server within 1 minute of being ripped.You definitely want a desktop for this, and not a server. Desktops have the added availability for more disk drives. Talking about disk drives, you can run down to goodwill and buy up all of their disk drives or their computers. I happened to get my SATA 2 disk drives for $5 a piece. I am also currently in the process of getting a

DNS | Homelab Basics

Special thanks to /u/releenc for reaching out to me and writing this edition of Homelab Basics. This edition is a bit longer than my other ones, but is very informative because he is a "DNS Professional" and explains the concepts very thoroughly. Homelab Basics - DNS By Robert Lee, /u/releenc on Reddit DNS (the Domain Name System) is one of the most important and fundamental network services used by everyone on the Internet. Unfortunately it is also one of the most widely misunderstood and misconfigured. The meme used among IT people troubleshooting problems that “It’s always DNS” is so pervasive because it’s true. In my 30 years of experience, if you cannot connect to something and there is not a network hardware error, it’s (almost) always DNS. The function of DNS is relatively simple. When a network device, like a PC, a smartphone, or anything else needs to contact another network device, it must do so using the IP address of that device. We as humans prefer to