Easy steps to recreate a reliable Raspberry Pi running 24/7 which:
- Will be able to restart tasks after a power outage
- Periodically saves backups of selected folders in Google Drive
- Can be easily restored after a SD card failiure
- Can be accessed remotely
Format the SD card using the Raspberry Pi Imager from https://www.raspberrypi.org/software/ and the raspbian image from https://www.raspberrypi.org/downloads/raspbian/ If you restore a prepared system, you probably don't need to follow next steps.
- Raspbian will ask you for another password, so set it.
- It will ask you for the country, timezone, WiFi, etc. so set them all. Recommended language is EN and recommended country is US for compatibility reasons.
Disable bluetooth if you're on Raspberry Pi 3 and you'll not use it. Then, go to Preferences > Raspberry Pi Configuration:
- In System, change the resolution to match the resolution of yout monitor and disable overscan (it will prevent resolution problems when the raspberry restarts while the monitor is turned off).
- In System, enable wait for network.
- In Interfaces, enable SSH.
Click on the CPU graphic on top right, and then click "Add / Remove panels". Add your desired information about the system, I personally add:
- Temperature Monitor
- Resource Monitors (for RAM usage, select Preferences > Display RAM usage)
Raspbian will try to automatically update itself during the setup, if you need to update it manually launch those commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get clean
For remote access within the same network, activate the VNC interface in Preferences > Raspberry Pi Configuration:
- In Interfaces, enable VNC.
For remote access outside the same network, install AnyDesk:
- Download and install raspbian armv7 32bit AnyDesk app from https://anydesk.com/en/downloads/raspberry-pi
- Disable the default remote access and enable it only through your AnyDesk account.
Disable the power and status leds guide
Edit the config and add the code block:
sudo nano /boot/config.txt
# Disable the PWR LED.
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
To relocate highly used directories into RAM, edit the next file and add the code block in the end:
sudo nano /etc/fstab
tmpfs /tmp tmpfs defaults,noatime,nosuid 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,size=16m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid 0 0
You can also modify the ext4 partition to reduce the writings into the SD (use your current PARTUUID!).
PARTUUID=XXXXXX-02 / ext4 defaults,noatime,commit=600 0 1
Execute those commands:
sudo su
dphys-swapfile swapoff
dphys-swapfile uninstall
apt-get -y remove dphys-swapfile
Now you'll be able to access into Raspberry using FTP, use a program like Filezilla to transfer files like installable packages. Get the IP of the machine placing the mouse on the top-right network icon. Remember to use the user 'pi' and the password you've entered on system setup.
Note: You can run
install-autostart.sh
from the SETUP folder to install the autostart automatically:chmod +x install-autostart.sh ./install-autostart.sh
Create LXDE-pi directory and its parents, and copy the autostart file into it. Then copy the startup.sh file into the home and give it execute permission, otherwise it will fail.
mkdir -p /home/pi/.config/lxsession/LXDE-pi/
cp autostart /home/pi/.config/lxsession/LXDE-pi/
cp startup.sh /home/pi/
chmod +x /home/pi/startup.sh
The autostart file will run on system boot, and it will call startup.sh to execute whatever is inside it. Put inside it what you want to be executed (in my case I execute multiple independent terminals).
https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=65607&sid=a1e7043538576960f65ae9e996dcfe29&start=25 https://www.raspberrypi.org/forums/viewtopic.php?t=277004