How to create a NAS with Ubuntu and USB External HDDs


I have been playing around with a few ideas on how to best create a low powered NAS. Initially I was planning to go with a Raspberry Pi but conceded that I already have a small Ubuntu server running anyway, so I should use the available resources. Most of the following guide is 100% transferable to a RPi so this document will be useful in future for me.

The Hardware:

  1. Lower Powered Asus Pizza Box
  2. USB Powered USB Hub (if your using a RPi then I suggest a mains Powered USB Hub)
  3. An old 160GB WD external HDD (which will be added to in future)


40,000ft Overview:

  1. Make a folder
  2. Mount the HDD to that folder
  3. Share the folder out using Samba


The Details:

First thing to do is mount plug it all in switch on the HDD and then mount it.

Create a folder which will represent the mounted hard drive:

sudo mkdir /media/wd1

Now find out the name of the HDD:

sudo fdisk -l

Then try mounting the HDD to the folder we created with:

sudo mount -t ntfs /dev/sdb1 /media/wd1


Now that the HDD is mounted we want to share it with our network, to do this we will use Samba. The following commands must be done as root:

sudo su

Install Samba:

apt-get update
apt-get install samba

We now have to set a password for our user in Samba as it uses a separate password than the system account. Note there must be a system user in existence already for the following to work.

smbpasswd -a <username>

Make a copy of the samba config to your home folder in case of a mistake:

sudo cp /etc/samba/smb.conf ~

Edit the samba config

pico /etc/samba/smb.conf

Add this to the end of the file:

path = /media/wd1
available = yes
valid users = <username>
read only = no
browsable = yes
public = yes
writable = yes

Now to restart the Samba server:

restart smbd

Check the config for any mistakes:


Now to access the HDD from the network on a windows machine use the following:


You will be prompted for your username and password (as defined by Samba)



Copyright 2021 OReillyIT. All rights reserved.