Raspberry Pi How To's
How to mount a NAS to your Raspberry Pi
-----------------------------------------------------------------------------------------------------------
If you have your hard drive or flash drive plugged into your router you must now configure and add to the 'fstab' file. You must also know the IP of your router. It is most likely going to look like this '192.168.1.1' or '10.0.0.1'. It will most likely have a 1 at the end.
You will need to make a folder in the Directory you want to mount your NAS Hard Drive in. I chose the /media
folder.
CD into the /etc folder.
Then: ls -l | grep fstab
You should see the 'fstab' file. Next:
sudo nano fstab
You must now add at the Bottom/End of the file what you want to mount. It should look something like this:
NOTE:"Do not copy and paste this script. It has double spaces in between what needs a space for visuals. There is no spaces after the comma's starting from the username to UTF8. This is one line, do not press enter to another line."
//192.168.1.1/USB_Storage /media/YOURFOLDER cifs username=pi,password=raspberry,_netdev,uid=1000,iocharset=utf8, 0 0
To save the file press CTL+X, then Y to save.
Reboot for safe precautions:
sudo reboot now
One reboot open the Terminal again and type in this command:
sudo mount -a
This should mount the NAS to the /media/disk1 folder and you can access the files through this.
NAS on OpenELEC(Kodi) Media Player
-----------------------------------------------------------------------------------------------------------
First you will need to enable the SSH on the OpenELEC in the settings. Connect to your network and then you can SSH into the Raspberry Pi OpenELEC OS. You will then create a directory in the /storage/ folder to your liking. I had to add Movies, because I'm using this for movies. Next you will create a config/mount file for the OS:
- cd /storage/.config/system.d/
- nano storage-movies.mount
("Note: Slashes "/" MUST BE REPLACED with dashes "-" with .mount as extension. This means, if we want to mount to "/storage/movies" then this file must be renamed to "storage-movies.mount". This is only for the filename! Not for the What= and Where= sections!")
Add these next lines of code to the file:
[Unit]
Description=nfs mount script
Requires=network-online.service
After=network-online.service
Before=kodie.service
[Mount]
What=//192.168.1.1/movies
Where=/storage/movies
Options=username=USERNAME,password=PASSWORD,rw
Type=cifs
[Install]
WantedBy=multi-user.service
Hit CTRL+X, Y, then ENTER To Save.
You can now Enable the CIFS Mount with this command:
- systemctl enable storage-movies.mount
Once that is done. Reboot:
- reboot now
Once Rebooted you can now update your files on the OpenELEC OS.
How to Back-Up your Hard Drive
-----------------------------------------------------------------------------------------------------------
So to start off with back up we need to figure out what file you want to back up. Then second you will want to know where you want to store these files. The command will use the "tar " program and you will be making it a tarball in the end for compression.
The Command: "Note: Do not copy and paste this command as it has double spaces for better visuals."
- sudo tar -czvf folder backup.tar.gz