Skip to main content

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):
[Data]
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.

Comments

  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?

    Thanks!

    ReplyDelete
    Replies
    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

      Delete

Post a Comment

Popular posts from this blog

Pretty git Log

SO you dislike git log output in console like me and do not use it... Because it looks like so: How about this one? It's quite easy... Just type: git log - - graph - - pretty = format : '%Cred%h%Creset -%C ( yellow ) %d%Creset %s %Cgreen ( %cr) %C ( bold blue ) <%an>%Creset' - - abbrev - commit - - It may be hard to enter such an easy command every time. Let's make an alias instead... Copypaste this to your terminal: git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" And use simple command to see this pretty log instead: git lg Now in case you want to see lines that changed use: git lg - p In order for this command to work remove  the -- from the end of the alias. May the code be with you! NOTE: this article is a rewritten copy of  http://coderwall.com/p/euwpig?i=3&p=1&t=git   and have b

Django: Resetting Passwords (with internal tools)

I have had a task recently. It was about adding a forms/mechanism for resetting a password in our Django based project. We have had our own registration system ongoing... It's a corporate sector project. So you can not go and register yourself. Admins (probably via LDAP sync) will register your email/login in system. So you have to go there and only set yourself a password. For security reasons you can not register. One word. First I've tried to find standart decision. From reviewed by me were: django-registration and django password-reset . These are nice tools to install and give it a go. But I've needed a more complex decision. And the idea was that own bicycle is always better. So I've thought of django admin and that it has all the things you need to do this yourself in no time. (Actually it's django.contrib.auth part of django, but used out of the box in Admin UI) You can find views you need for this in there. they are: password_reset password_reset_

Time Capsule for $25

The real article name might be something like:  Configuring Raspbery Pi to serve like a Time Capsule with Netatalk 3.0 for Mountain Lion.  But it's too long ;) Here I will describe the process of using Raspberry Pi like a Time Machine in my network. To be able to backup your MAC's remotely (Like it would be NAS of some kind). It assumes you have a Raspberry Pi and have installed a Raspbian there and have a ssh connection, or somehow having access to it's console. Refer to my previous article for details . Now that we have a Pi that is ready for action let's animate it. So to make it suit you as a Time Capsule (NAS) for your MAC's you need to do those basic steps: - connect and configure USB hard drive(s) - install support of HFS+ filesystem to be able to use MAC's native filesystem - make mount (auto-mount on boot) of your hard drive - install Avahi and Netatalk demons - configure Netatalk daemon to make it all serve as a Time Machine - configure