Raspbery Pi as a home file server
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
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
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.