Raspbery Pi as a home file server

I've wanted more from my PI, besides Time Machine functions, established in my earlier articles. So I've decided to make it a SAMBA server. I have a Mac and a Windows PC. And several iPads/iPhones. So the decision was obvious. To access my storage content I'd need a samba share. Because it is recognized by all this tech. iPad has Oplayer, to watch movies without conversion... GoodReader for docs. One word - SAMBA share. SO this article will be about adding a samba share to your Raspberry Pi.
Note I have a Time Machine already set up. But it won't matter much. I only have another drive index letters and so on. I'll try to cover this as much as possible. And macs somewhat easily read NTFS filesystems. So we will be mounting NTFS filesystem volume to a Raspberry Pi with SAMBA network sharing. Let's get on to it.

To set up a Raspbery Pi home network Samba server you will need to:
- Connect an external drive (USB HDD in my case).
- Update fstab for auto-mounting of it on system boot
- Install and configure samba
- Enjoy

1. Connecting an external USB drive.

Assuming you hava an external hard drive connected type the command:
pi@raspberrypi /mnt $ sudo blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" UUID="XXXX_XXXX" TYPE="vfat" 
/dev/mmcblk0p2: UUID="XXXXXX_XXXXXX_XXXXX_XXXX" TYPE="ext4" 
/dev/sda1: UUID="XXXXXXX-XXXXXXX-XXXXXXX-XXXXX" LABEL="Time Machine" TYPE="hfsplus" 
/dev/sdb1: LABEL="Data1" UUID="5XXXXXXXXXX1" TYPE="ntfs"
Note I have sda1 drive with hfsplus filesystem for AFP shares so my NTFS drive is named sdb1. Yours will probably be sda1 out of the box. Note that. We now see the NTFS hdd. Lets make it mounted. Typing mount command will show it's not yet there.
pi@raspberrypi /mnt $ mount
/dev/root on / type ext4 (rw,noatime,user_xattr,barrier=1,data=ordered)
# ...
/dev/sda1 on /mnt/TimeMachine type hfsplus (rw,nosuid,nodev,noexec,relatime,umask=0,uid=0,gid=0,nls=utf8)

2. Update fstab for auto-mounting of it on system boot

Lets make a directory for mounting a drive:
pi@raspberrypi /mnt $ sudo mkdir /mnt/data
Now lets update fstab to add a setting for proper auto-mount of our drive on boot.
pi@raspberrypi /mnt $ sudo nano /etc/fstab
Lets add a line. Something like.
UUID="XXXXXXXXXXXXXX" /mnt/data ntfs rw,auto 0 0
Where UUID is your device UUID, that you can find out using sudo blkid command.
Now we can either reboot or mount a hard drive. I choose to mount. Lets type:
pi@raspberrypi /mnt $ sudo mount /dev/sdb1
pi@raspberrypi /mnt $ mount
/dev/root on / type ext4 (rw,noatime,user_xattr,barrier=1,data=ordered)
# .....
/dev/sdb1 on /mnt/data type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
And our drive is mounted and will be auto-mounted on each reboot.

3. Install samba

Now lets move on to installing samba server for our network sharing. Lets do it with apt-get:
pi@raspberrypi /mnt $ sudo apt-get install samba
Confirm additional package downloads by typing y to the prompt of this command. And wait while it installs some demons and defaults.
Now lets edit the default samba config:
pi@raspberrypi /mnt $ sudo nano /etc/samba/smb.conf
And add the config of our drive to the end of this config file. (After numerous other parameters):
comment = DataDrive
read only = no
locking = no
path = /mnt/data     
guest ok = yes
force user = pi
After this is done simple restart of samba server will be sufficient:

pi@raspberrypi~$ sudo service samba restart

4. Enjoy

Now I have a file dump server I ever dreamed of. I can connect as guest with all my devices and have a cross platform decision built on a PI platform.
And this all stuff looks like this now. With a second ntfs external HDD and my Pi in Punnet MK1 paper case.


  1. Hi Iurii,

    Thanks for the write up, it's been a big help. But I can't get the samba share to work. The share shows up in my finder, but when I click it it gives the error: The operation can’t be completed because the original item for “Media Player” can’t be found.

    Any idea what I might need to check?


    1. I think it's because your media player in system not configured to play network shares. Try deleting the indexing data in the share itself. E.g. Thumbs.db etc.. Whatever system you are using there


Post a Comment

Popular posts from this blog

Python converting PDF to Image

How to disable/enable an element with jQuery or Javascript

Django: Resetting Passwords (with internal tools)