Raspberry pi - NAS (Network attached storage)

Use Cases

  • Data stored at one place
  • Videos can be streamed on ipad or iphone
  • All the devices are equivalent. I can read a pdf on my laptop, then
    on ipad or iphone

Abstract

  • Raspberry pi
  • External hard disk
  • Powered usb hub

My hard disks are attached to one powered hub. This powered hub is important, otherwise external hard disk will not get enough power from Raspberry pi and will not be available.

Setup steps

Since we already have the instruction published on various forums. I can just point you to the links that realy worked for me. Please follow the steps mentioned on the following links. Let me know if you run into any issues or have any specific questions.

http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html

http://www.dingleberrypi.com/2013/05/turn-a-raspberry-pi-into-a-nas-network-attached-storage-server/

Few snaps from my configuration

sudo lsblk -f

ls -l /dev/disk/by-uuid

/etc/fstab file

I have three hard disks. I have named them anantvijay, devdatta, paundram ( three conches from mahabharat epics).

As you can see, it is better to map the disks based on UUID rather based on /dev/sd* value. Becuase /dev/sd* mapping will change every time Raspberry pi or harddisks are restarted. So mount directory will have different data every time. Please refer to the following for UUID details -
https://wiki.archlinux.org/index.php/persistent_block_device_naming

All in One (For copy/paste)
The following commands will mound the three drives using their UUID. Please change the UUID for your disk.

sudo mkdir -p /media/usbhdd/anantvijay
sudo mkdir -p /media/usbhdd/devdatta
sudo mkdir -p /media/usbhdd/paundram

sudo vi /etc/fstab

 ==Insert the following in /etc/fstab file
 UUID=4E1AEA7B1AEA6007 /media/usbhdd/anantvijay ntfs-3g uid=pi,gid=pi,file_mode=0777,dir_mode=0777 0 0
 UUID=537A-B383 /media/usbhdd/devdatta vfat uid=pi,gid=pi 0 0
 UUID=03CC-87BF /media/usbhdd/paundram vfat uid=pi,gid=pi 0 0
 ===
 sudo apt-get install ntfs-3g
 sudo mount -a

All in one for samba ( for copy/paste)

sudo apt-get install samba samba-common-bin
sudo vi /etc/samba/smb.conf

===
[pi@devdatta]
    comment=pi at devdatta
    path=/media/usbhdd/devdatta
    valid users=pi
    browsable=yes
    writeable=yes
    only guest=no
    create mask=0777
    directory mask=0777
    public=no

[pi@anantvijay]
    comment=pi at anantvijay
    path=/media/usbhdd/anantvijay
    valid users=pi
    browsable=yes
    writeable=yes
    only guest=no
    create mask=0777
    directory mask=0777
    public=no

[pi@paundram]
    comment=pi at paundram
    path=/media/usbhdd/paundram
    valid users=pi
    browsable=yes
    writeable=yes
    only guest=no
    create mask=0777
    directory mask=0777
    public=no
===
sudo smbpasswd -a pi [Enter any password, this will be asked when you try to map the drives]
sudo /etc/init.d/samba restart

/etc/samba/smb.conf