I am going to take you through how to setup a Raspberry Pi NAS.  We will be using SAMBA & the format for the external HDD will be HFS+

HFS+ is the Macintosh standard format, I used this HDD with my mac & put a lot of data on it. I decided to set it up as a NAS rather then having it plugged into my macbook all the time. So naturally I don’t want to format it & lose my data.

There are a lot of benefits to setting up a Raspberry Pi NAS. It’s energy efficient, Cheap, uses USB external HDD’s (great for portability), setup data redundancy, using a stable & reliable Linux OS – Debian. ETC

First make sure your Raspberry Pi is ready to go.
Install RASPBIAN – The easiest way to do this is to follow this guide & install the NOOBS package.

Once you have your working Raspberry Pi plug it into the network (LAN is preferred, but WiFi will work) & SSH into it using Terminal or for windows users you can use PuTTY or Cigwyn.

SSH - Raspberry Pi NAS


If you haven’t changed your PW yet, the default for the pi user is: raspberry

Now lets update the Raspberry Pi.

Run these  2 commands one after each other

sudo apt-get update
sudo apt-get upgrade

Now we need to install some repos

HFS+ Support

sudo apt-get install hfsprogs

HFS+ uses GPT (GUID Partition Table) so fdisk won’t support it, this is why we need to install gdisk

sudo apt-get install gdisk

Once these are installed lets get to mounting the drive, but first we need to create a directory to mount it to. (3TBEXT is what I called my directory, you can call it whatever you please)

sudo mkdir /media/3TBEXT

Plug in your HDD & lets make sure the device is detected in fdisk

sudo fdisk -l

fdisk - Raspberry Pi NAS


We can see that the 3TB external HDD is /dev/sda but we need to know the partition to mount, fdisk can’t show us this because it doesn’t support GPT.

So we will use gdisk which we installed earlier to check the device path for the partition.

sudo gdisk -l /dev/sda

We can now see that its partition number 2. The device path will be /dev/sda2 (you could of easily guessed this but its always better to double check)

gdisk - Raspberry Pi NAS

Lets mount the drive

sudo mount -t hfsplus -o force,rw /dev/sda2 /media/3TBEXT

Now that the drive is mounted lets add them to the fstab which will mount the drive every time the Pi reboots.

sudo nano /etc/fstab

add another line for your HFS+ drive

/dev/sda2       /media/3TBEXT    hfsplus defaults,force  0       0

How To Make A Raspberry Pi NAS Using SAMBA & HFS+

(each space is a tab, not a space)
Exit & save by pushing CTRL X then Y  & Enter

Now we can install SAMBA which is the windows sharing protocol. (this works fine across all platforms)

sudo apt-get install samba samba-common-bin

Once it’s installed we can configure it. But first incase you make a mistake lets backup the config file.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bkup

Now that we have our backup config file lets edit the main one. (CTRL V to scroll through the pages, if you aren’t familiar with nano I recommend you check out the user guide)

sudo nano /etc/samba/smb.conf

SAMBA Conf - Raspberry Pi NAS

You can change the workgroup here as well but default is fine in my case, which is “workgroup”

Workgroup Conf - Raspberry Pi NAS

When you get to Authentication you need to remove the # symbol from security = user so it enables user base authentication with your shares. (depending on the version of samba you installed this might not be there. Just add it if its missing)

Security Conf - Raspberry Pi NAS

Now go all the way to the bottom of the config file & add your share. (what you put in brackets in the top line will be the name of the folder that appears on the network share)

comment = Raspberry Pi NAS
path = /media/3TBEXT/
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no

Now exit the same as we did before.
CTRL X then Y  & Enter

Restart Samba

sudo /etc/init.d/samba restart

We now have to create a user that can access the samba shares. (change *username* to what you want your user name to be)

sudo useradd *username* -m -G users

sudo passwd *username*

You’ll be prompted to type in the password twice to confirm. Now we can add this user as a samba user. (once again replace *username* with your user name)

sudo smbpasswd -a *username*

Enter the users password again when prompted.

And now we are done!
If you open finder you will see the Raspberry Pi NAS appearing in shared section of the sidebar. Click on it & click the button in the top right that says *Connect As* & put in the user credentials you created & you will have access to the network share.