Configuring your raspberry pi as a NAS server.
You can buy self contained NAS drives now, but if you’ve already got a large USB drive and want to share it on your network, you can configure a raspberry pi to act as NAS server for you.
It’s really easy. First of all you need to set up the system to mount the disk automatically on bootup. Under debian wheezy the first USB drive to connect up is /dev/sda1. So you need to create a mount point for it:
sudo mkdir /mnt/myusbdrive
Then edit the /etc/fstab file to include a mount instruction for the disk; “fstab” will contain a line for every file system the needs mounting automatically; by default it looks like this:
proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/mmcblk0p2 / ext4 defaults,noatime 0 0
Add this line at the bottom using the nano editor (“sudo nano /etc/fstab”):
/dev/sda1 /mnt/myusbdrive auto defaults,noexec,umask=0000 0 0
At this point if you shut down and restart the pi then you should see the disk being automatically mounted and its contents visible at /mnt/myusbdrive.
Next you need to install Samba, the windows networking software. This will make it easy to connect to the server from both windows and linux machines:
sudo apt-get install samba
Then you need to edit /etc/samba/smb.conf to add in a share. Towards the top of the file the workgroup is set. It defaults to “WORKGROUP” and if this is what your network is set up for then leave it, otherwise change it to suit:
workgroup = WORKGROUP
Add the following lines to the end of the file:
# # Samba share for Network stuff [NAS1] path = /mnt/myusbdrive comment = Shared network storage guest ok = yes force user = pi create mask = 0775 directory mask = 0775 read only = no
The word in brackets “[NAS1]” is what the network share is called. It doesn’t need to be upper case and can include spaces.
Samba SHOULD restart itself when it notices that its config file has changed.
These settings assume its OK to allow anyone all access to the disk and the files on it. How to configure for more security is a complex issue and beyond the scope of this article. However there are MANY artcles on the internet about securing Samba shares, and google or Yahoo! should help you find them. Or even Bing.
Version 2 updated 12 Nov 2013, 10:12 a.m.