zaterdag 8 september 2012

Raspberry Pi NAS

This documents my setup of my Raspberry Pi as a cheap NAS

Initially I followed http://elinux.org/R-Pi_NAS but ran into some problems.  Especially the section on 'Adding USB storage' and more specifically 'Remount USB storage on startup' don't seem to be working for me. (might be my fault)

I finally got things working by following some tips on this page which actually made my system work.

I'm currently experimenting with a cubieboard as alternative to this raspberry pi NAS setup. Read about it here.

The following is a rude mash-up of the above mentioned sources, so all credit to them.

So basically, once logged in to your raspberry pi that is connected to the internet, you can do the following:

General setup
sudo apt-get update
to put your system up-to-date
sudo apt-get install samba samba-common-bin
installs samba binaries
sudo apt-get install autofs
allows you to automatically remount your usb drive when your raspberry pi restarts
sudo mkdir /home/shares
sudo mkdir /home/shares/public
sudo mkdir /home/shares/public/disk1
sets up the directory structure where your USB hard drive will get mounted

fstab setup
sudo cp /etc/fstab /etc/fstab.old
copy fstab file, just to be sure
sudo vi /etc/fstab
edit the fstab file by adding the following to the end
/dev/sda1  /home/shares/public/disk1  ext3 defaults  0  0

(I defined my USB drive as ext3 as I reformatted it to ext3 before starting to use it)

sudo mount -a
mounts all drives that are not mounted yet
ls -al /homes/shares/public/disk1
ideal time to see if you messed up your fstab file

automount setup
sudo vi /etc/auto.master
add the following
/media/ /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000
after
+auto.master

Samba setup
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
copy file, just to be sure
sudo vi /etc/samba/smb.conf
edit the file, add the following to the end of the file:
### USB share definition###########################
[usb]
comment = USB
sharepath = /home/shares/public/disk1
writeable = yes
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
browseable = yes
###################################################

sudo service samba restart
restarts samba and activates the changes you added


sudo smbpasswd -a pi
adds the pi user to the samba users

So I hope I got this complete and correct. Please also consult the 2 sources I mention at the beginning as these form the bases of my mash-up.