Media NAS Pi Server

2022-05-03

I decided to setup my local NAS server using a raspberry Pi and a USB connected SSD. This will involve installing and configuring samba on the raspberry Pi to allow access from Windows.

Here are the steps I followed in order to get everything working.

  • If your setting up your raspberry Pi for the first time, install the Raspberry Pi Imager which will allow you to install the Raspberry Pi OS (aka Raspbian) onto an SD card.
  • Once you installed the Raspberry Pi Imager install the latest headless (aka desktop free) software. Ensure that you give your Pi a hostname and enable SSH.
  • Connect your raspberry Pi to your network. My raspberry Pi has the PoE hat hence once I connect it to my network via Ethernet it will recieve power.
  • Connect your external SSD drive ensuring that it has been formatted correctly. SSH to your pi and run the following to determine whether your SSD has connected:

sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

  • You should see a similar result to this:

List Disks

  • You should be able to see your drive in the list, take note of the path at the beginning and the label.
  • You'll need to create a folder of the location where you would like to mount your external device
    • sudo mkdir /mnt/main-share-1
  • Mount the external drive onto the share locations.
    • sudo mount /dev/sda2 /mnt/main-share-1
  • Change permissions on /mnt directory
    • sudo chmod 775 /mnt/main-share-1
  • Create a separate user for accessing the media files. Follow all the steps in the user creation wizard.
    • sudo adduser mediapi
  • List the users just to confirm that the creation went successfully List users
  • Install samba and then backup the config
    • sudo apt install samba
    • sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bk
  • Edit samba config
    • sudo nano /etc/samba/smb.conf
  • Add the share info at the bottom
        [main-share-1]
            comment = Samba on Ubuntu
            path = /mnt/main-share-1
            read only = no
    browsable = yes
  • Then save the file
  • Restart samba server
    • sudo service smbd restart
  • Update firewall rules to allow samba
    • sudo ufw allow samba
  • Setup samba user
    • sudo smbpasswd -a mediapi

The NAS configuration is complete and you should be able to access the server from a Windows PC.

  • Go to your Windows PC and open a run dialog and type in the IP address followed by the share path in the UNC format:

UNC share for NAS drive

If you want you can add the network location share permantley in Windows.