NAS on the Pi
Setup a Hard drive
You can connect any USB hard drive to your Pi.
Remember one thing: if your HDD is self-supply through USB, you may need an intermediate HUB. Indeed, the Pi may not be able to provide enought current itself. Then please, set your hardrive in EXT4 format (not NTFS as default.)
First, find the correct sdaX element:
sudo blkid Then change the file system with this command:
sudo mkfs.ext4 /dev/sda4
apt-get install hdparm -y
mount /dev/sda1 /media/Hard_drive/
Add this line:
/dev/sda1 /media/Hard_drive ext4 defaults 0 0
Access on Windows
In order to see your drive on Windows network folder, you need to setup Samba.
apt-get install apt-transport-https samba samba-common-bin
cp /etc/samba/smb.conf /etc/samba/smb.conf.old
Access on Linux
In order to see your drive on linux, you just need to configure it in your file browser.
This works also with distant server.
For Linux Mint, the browser is Nemo.
Just go to "File" ==> "Connect to a server" !(server.png)
Then, you need to provide your IP (or domain name), user and password.
Synchronise on Windows
Synchronise on Linux
For synchronisation on Linux, let's take a common case.
The computer user folder should be copy every night at 23h to the raspberry pi server.
This copy should be incremental, means except for the first time, the action should not be take long time.
This command will for example sync the user folder GERARD without some folders (cache) on the hard drive connected to the server:
sudo rsync -av --ignore-existing --exclude .cache/ --exclude .mozilla/ /home/GERARD/ firstname.lastname@example.org:/media/Hard_drive/Personnal/GERARD
For a schedule task:
You first need to set the authenfication through SSH keys, otherwise the password prompt will block the process.
Please refer to the other pages of this blog.
Then go to Cron:
Add a similar line:
20 23 * * * rsync -avzhe "ssh -i /root/.ssh/id_rsa -p 22" --ignore-existing --no-perms --no-owner --no-group --exclude .cache/ --exclude .mozilla/ --log-file=/var/log/rsync/backup-log-`date "+\%Y\%m\%d_\%H\%M"`.log /home/GERARD root@raspberry:/media/Hard_drive/Personnal/GERARD
For this example: this action will be trigerrred every day at 23h20.
The computer will connect with the raspberry through RSync/SSH and synchronise the GERARD folder (with some exclusions).
Synchronise on phone