How to set-up a SAMBA server. | Ubuntu Server | DIY NAS -thebytewise

For this project, you can use any old PC lying around in your house, any old hardware will work with this setup. You can even use a Raspberry Pi for this setup. I myself used a 10 years old PC I found lying around in my house.

Although if you don't have any old PC you can also use your existing one, although that won't be the ideal choice for a server because first of all, the main objective of a server is to be connected to the network at all times so that all the users can actually use the server simultaneously. So it will be better to set it up on a different PC.

So, let's dig into the setup.


Prerequisites


  1. Make sure the PC you are using has a decent enough Hard Drive, that you can rely on. If not this will be a good time to invest in a new Hard drive.

  2. You will need a router or switch to connect the server.

  3. You will need an external monitor and keyboard for the initial setup and if possible keep it plugged in (Not necessary though this is just for future upgrades which can be also done using an SSH connection).

  4. This won't be the fastest server you can get for your money but it is decent enough for storing files and streaming media directly from the server. Although don't expect it to be able to play and edit 8K videos directly off the server.


Step1: Installing Ubuntu server


For this project, we are going to use the ubuntu server, so if you are using your current PC you can skip this step and continue from step 2. Do note that this project is a Linux based server, that means if you are using windows or mac you can go to other websites suggesting the correct way of doing that on the respective Operating System.


  • Okay, so the first step will be to download the disk image for Ubuntu Server 20.04 from their official website https://ubuntu.com/download/server.

  • After downloading the image flash it onto a USB drive and plug it on the PC you are using for the build.

  • Plug your PC to a wall outlet, before turning it on make sure you have connected it to your home router using an ethernet cable.

  • Now boot from the USB drive instead of the HDD (go to your BIOS setup and change the boot device priority).

  • It should boot into the installation wizard. Follow the setup steps. You can leave most of it at default, but do remember to check the "Install open SSH server" option, if you wish to connect to the server remotely.

  • After installing, log in with your username and password and issue an update-upgrade command to update the system.

sudo apt-get update && sudo apt-get upgrade -y

Step 2: Installing Samba


The next step is to install samba on your pc. For this make sure your system is up to date. You can use the update-upgrade sequence to update your PC.

  • after the update process is done we need to install samba using the following command.

sudo apt-get install samba

Step 3: Adding users and creating shared directories


  • After installing samba, we need to configure user accounts, you can add as many users as you want.

sudo adduser [username]

replace [username] with your desired username.


  • Now we need to make directories and add permissions. Again you can make as many directories and subdirectories you want.

sudo mkdir [directory name]

replace [directory name] with your desired directory name.

  • Give permissions to the directories. This is a home server so we will just allow everything.

sudo chmod 777 [directory name/path]

repeat this step for all the added directories and subdirectories


Step4: adding users to samba


  • Now we need to create samba passwords for all the users.

  sudo smbpasswd -a [username]

replace [username] with the user you added and repeat this for all the users


Step 5: Editing the smb.conf file

  • Now to we need to edit the smb.conf file for setting up the shared directories

sudo nano /etc/samba/smb.conf

after opening add the following lines at the end of the file

[directory name]
path = /home/[default username]/[directory name]
browseable = yes
read only = no
valid users = [user1] [user2] [user3]

You have to do this for all the directories and subdirectories, and you can edit the valid user list according to your needs. After adding these lines you can press ctrl + o then enter to save and ctrl + x to exit


Step6: Setting up a static IP for the server


  • For the device to work seamlessly we need to set up a static IP for the server. Enter the following commands on the terminal.

netplan generate
  • Now open the netplan config file using any editor

sudo nano /etc/netplan/00-installer-config.yaml
  • Delete the old text and add the following. Remember to change the ethernet adapter (ens32 for my system) to your server's ethernet adapter. You can find it by issuing an ifconfig command.

network:
    ethernets:
        ens32:
            addresses:
            - [desired ip]/24
            dhcp4: false
            gateway4: [your gateway]
            nameservers:
                addresses:
                - 8.8.8.8
                - 8.8.4.4
                search:
                - workgroup
    version: 2

After adding these lines you can press ctrl + o then enter to save and ctrl + x to exit.

You can find out the gateway (generally it is your router's IP address) by issuing the ifconfig command on the terminal. Note that by default it may not work on ubuntu server 20.04, for that just install net-tools by typing:

sudo apt-get install net-tools.

  • now apply the changes

netplan apply

That's it you are done, now restart the system and you are ready to go. You can connect to it using all your devices on the same network as of the servers.


Follow these steps to connect to your network drive.


For Windows: https://support.microsoft.com/en-us/help/4026635/windows-map-a-network-drive


For Linux:

  1. Go to your file manager

  2. click on file>connect to server...

  3. then enter the details


For mac: https://osxdaily.com/2012/05/04/automatically-connect-to-network-drive-mac-os-x/


Now you have your own Network Attached Storage server where you can store files and use it to stream media on all your devices.

29 views
  • Facebook
  • Instagram

©2020 by thebytewise. All Rights Reserved