TODO:
- script to automate gui config on NC
- script to automate gui config on Plex.
-
Rename main external hard drive to HD_1 and back up to BU_1, follow ths convention for all subsequent drives and add these details (alongsde the signal pin) to config.json. Make a dir to store Plex metadata on HD_1 i.e. HD_1/Media/metadata.
-
note Synch drives before setting up as MUCH quciker if large and popultated (use Free file sync).
-
Ensure HD_1 is attatched to permenant usb and BU_1 attatched to realy controlled USB.
Download SD card formating software: https://www.sdcard.org/downloads/formatter/
Format card on local machine:
Download Raspberry Pi Imager: https://www.raspberrypi.com/software/
Run Raspberry Pi Imager and flash OS,
version:
Raspberian Lite 64bit
Select settings (cog wheel - lower right)
Select 'Enable shh' Select 'Use password authentication' 'set authorised keys' auto fills to local user. enter username and password. DO NOT USE DEFAULT USERNAME & PASSWORDS.
Select 'Configure wireless LAN option and enter network details.
Local settings auto filled, if not complete.
Set hotsname as Pi , enable SSH and select use password authentication.
Save and write SD, takes a few minutes. Insert SD and turn on Pi, navigate to router on local network (192.168.1.1 for me) and login to router, navigate to connected devices and find Pi address.
-
On network connected computer open terminal/Powershell and run the following command, if this is the first time connecting you will be prompted for ssh fingerprint, type yes.
ssh <username>@192.168.1.x -v
Note: if this has been done before and is fresh installation, navigate to C://users/user/.ssh/known_hosts and delete previous fingerprint.
-
As using raspberian Lite we need Git and pip so run:
sudo apt-get install git -y
sudo apt install python3-pip -y
-
Clone this repo:
git clone https://github.com/scottolivermorgan/NAS_drive.git
Note: if the following error occurs:
error: RPC failed; curl 16 Error in the HTTP2 framing layer
retry cmd, else if error persits Run:
git config --global http.version HTTP/1.1
and re- try the clone cmd
-
Install Python requirements:sudo sh scripts/update.sh
cd NAS_drive && sudo pip install -r requirements.txt --break-system-packages
-
Update packages and reboot Pi:
sudo sh scripts/update.sh
-
After reboot, reconnect via SSH and run:
cd NAS_drive && sudo python main.py
follow onscreen prompts, halfway through you wll be prompted to enable external drives for nextcloud follow instrutions below.
Access nextcloud at 192.169.1.x/nextcloud fill out form adding user and usng database user and password set in terminal prompts with database name nextclouddb. Browser will return error message once set up, vistit 192.169.1.x/nextcloud and:
Click top right userprofile icon and select Apps.
Scroll list and select Enable on External Storage support
Wait several seconds, again select user icon at top right and select Administrator settings.
Select External storage tab on left and add name, Local, and add mount point defined in mount-drives.sh - /media/hardrive1
Return to the terminal, enter y and hit enter, reboots on completion
- After reboot, reconnect via SSH and run:
sudo -u www-data php /var/www/nextcloud/occ files:scan --all --verbose
Note: Can take up to 2 hours.
Note: SSH port changed from 22 to 1111
Access Plex at 192.168.1.x:32400/web -x dependant on your local network.
Sign in/create account and addexternal lib via GUI Add Libary > harddrive1 (in this case as has been set in previouse steps)
Relay wiring:
note GPIOs 0-8, 14 & 15 appearhigh at boot, if connected to these pins relay will power up, connect 2nd HD then power down so don't use these pins. Relay Pin + = 5v Power (board no# 2) - = Ground (board no# 14) s = GPIO 14 (board no# 8)
Pi dosen't ship with power off button, shutting down cleanly avoids SD card corruption so add a switch and python script to enable clean shutdowns before turing off at plug.
Use board pins 39 (ground) and 40 (GPIO21):
Resources: https://help.nextcloud.com/t/how-to-access-from-outside-your-network/126311 https://techmadeeasy.co.uk/2020/03/access-a-nextcloud-server-from-outside-your-home-network/ Nextcloud desktop client: https://nextcloud.com/install/#install-clients
Set up account and domain name with following DDNS service: https://www.noip.com/
Open SSH to Pi andchange dir to
cd /var/www/html/nextcloud/config
Open config file
sudo nanoconfig.php
add domain name to
'trusted_domains' => array ( 0 => '192.168.1.100', 1 => 'your.ddns.domain', ),
Set up port fowarding rules on router
- The PHP memory limit is below the recommended value of 512MB
sudo nano /etc/php/8.1/apach2/php.ini
change line:
memory_limit = 128M
to
memory_limit = 1G
Download & install imaging software: https://sourceforge.net/projects/win32diskimager/
-
Insert SD card from Pi & Open Win32 Disk Imager, check drive letter and select under device dropdown:
-
In pop up navigate to desired save location and enter desired image name, ensure file extenino is .img
Select read option to save, operation can take 10 -20 mins.
NOTES
lsblk -o PATH,FSTYPE,LABEL,UUID | grep "BU_1"
lsblk -o LABEL,UUID | grep "BU_1"
lsblk -o LABEL,UUID | grep "BU_1" | awk '{print $2}' sudo mkdir /mnt/mydrive
sudo mount -U /mnt/mydrive