This article on building a Raspberry Pi NAS solution has been sitting in my drafts for three years now. Recently, my Raspberry Pi had stopped working (the SD card had died), so I rebuilt it yesterday. I cursed myself for not having finishing the text back then, as I now had to retrace some steps manually. So, here goes the finished procedure for future reference.

I got a Raspberry Pi as a birthday present from my thoughtful colleagues!

Now, as my first project I decided to connect it to my 2TB external hard drive and serve it on my local network using the Samba protocol (I tried NFS and SSH too, but Samba proved to be the most performant protocol and is also cross-platform). No more moving the disk around and hooking up USB cables 🙂

Mounting an external drive

Since Raspberry doesn’t feed much power through its USB port, you’re going to need a HD with its own power supply or a powered USB hub.

To auto-mount the drive (in my case it was an NTFS drive, some googling will help for other filesystems) find the necessary data.

sudo blkid # to find the partition name id # to find the uid and gid

Create a folder where we will mount the drive.

sudo mkdir -p /media/data

Make sure you have all the dependencies installed.

sudo apt-get install ntfs-3g

Now add this line to /etc/fstab – edit the /media/data path, uid and gid to suit your needs. Don’t forget to input a newline at the end.

UUID=868A1CE88A1CD711 /media/data ntfs rw,auto,user,nls=utf8,umask=003,gid=1002,uid=1001,dmask=027,fmask=137,nobootwait 0 0

If you don’t care about permissions too much, you can also just go for a simpler config.

UUID=868A1CE88A1CD711 /media/data ntfs rw,auto,defaults,nls=utf8,nobootwait 0 0

Now try mounting it using sudo mount -a and make sure that you can access the data afterwards. If you get stuck here, try learning a bit more about mounting disks from this Ask Ubuntu question or this nice wiki.

Serving the disk over Samba

First off, important note – make sure that your Pi’s hostname is less than 15 characters, otherwise you will get errors trying to mount the Samba folder!

Get the Samba dependencies.

sudo apt-get install samba samba-common-bin

Create a Samba password for your user (replace pi with your actual user).

sudo smbpasswd -a pi

Edit /etc/samba/smb.conf to contain the following settings (you can modify the existing file):

[global] workgroup = HOME # for Win 7/8 socket options = TCP_NODELAY # ... on the bottom of the file [USB] path = /media/data comment = RPi data partition valid users = pi # make sure you have the right user here writeable = yes browseable = yes

Restart Samba

/etc/init.d/samba restart

Back on the client machine

Take a look at the mounting SMB wiki for info on mounting your Raspberry drive on login in a Linux desktop OS. This site offers instructions with screenshot on setting up the network drive in Windows. On OS X, you should see the Raspberry Pi under network (or as shared in Finder or you can go to Go… -> Connect to Server… and enter smb://<ip address> .

That’s it. Here is my boy in his shining armour made out of Legos:

Resources

Jeremy Morgan’s SMB server instructions – a very simple, yet effective solution. This helped me get out trouble when I got into some dead end with all the other tutorials

TechnoCanuk’s extensive NFS and SSHFS instructions – you can find an abundance of instructions here, with some good troubleshooting tips

TechSwamp’s tutorial – another nice tutorial, also covering the DLNA setup