Pages

New domain and blog

Please head over to my new domain to view my blog and current projects

Tuesday, 12 March 2013

Raspberry Pi: NAS server

I have been wanting to set up my Raspberry Pi as a Network Attached Storage (NAS) drive for quite some time. I eventually got a chance yesterday to give it a go. Unfortunately the Raspberry Pi USB port can't power my external hard drive and I don't have a USB hub at the moment, so I just used a 16GB flash drive.

First you need to format your external drive with NTFS. Then place a file on it. Any file will do. I chose a text document so that I can open it and view it on the Pi. Once you have set up your drive, turn off your RasPi, plug the drive into the USB port and then turn on the RasPi. It is safer to plug the USB in when the RasPi is off because some versions don't have poly fuses on the USB ports.

Once booted up, log in and check to see if the drive is connected.

sudo fdisk -l

You can see that my connected drive is right at the bottom. The drive is called sda and because there is only one partition, it is called sda1.

Next you need to create a folder where your drive is going to be mounted into. I called mine myHadrDrive. You also need to give the folder root access so that when you connect to it you are able to read from it and write to it.

sudo mkdir /mnt/myHardDrive

sudo chmod 0777 myHardDrive

Next you need to mount the hard drive to the folder that has just been created. Open fstab and add the following line to the bottom of the file where it reflects your setup.

sudo nano /etc/fstab

Mount the drive

sudo mount -a

Now we need to install and set up the Samba server. This will allow a windows machine to connect to the RasPi over the network. Start by installing the following packages using apt-get.

sudo apt-get install samba

sudo apt-get install samba-common-bin

sudo apt-get install ntfs-config

sudo apt-get install ntfs-3g

Once all of those packages are installed, edit the Samba configuration file. It took me a while to get this right but with the help of this video, I managed to get it.