Raspberry Pi

TODO RSS

TODO Syncthing user

Raspberry Pi OS headless installation

Sources:

From the desktop

Installation - Manual

Download the latest Raspberry Pi OS

Find the SD card :

1
sudo ls -ltr /dev/

Or

1
ls /dev/mmcblk*

Result should be something like

1
2
3
/dev/mmcblk0
/dev/mmcblk0p1
/dev/mmcblk0p2

mmcblk stand for SD card, 0 is the number and p* are for SD card partitions.

So here the SD card is /dev/mmcblk0

Install Raspberry Pi OS to the SD card

1
sudo dd bs=1M if=/path/to/raspberry-pi-os.img of=/dev/sd_card status=progress conv=fsync

When Raspberry Pi OS is installed, re-plug the SD card. At this point you should see 2 mounted devices boot and rootfs.

Headless configuration
1
cd /path/to/boot/partition

Enable ssh by default

1
touch ssh

Activate wifi at startup

1
vim wpa_supplicant.conf

then write

1
2
3
4
5
6
7
8
9
country=fr
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid="SSID_box"
 psk="password"
}

Set up hostname

1
vim etc/hostname

Replace by berry.

1
vim etc/hosts

Replace 127.0.1.1 raspberrypi by 127.0.1.1 berry.

Installation - RPI Imager (Deprecated)

1
sudo dnf install rpi-imager

Use RPI Imager to install Raspberry Pi OS on SD Card.

CTRL+SHIFT+X to access advanced options :

  • Set up user
  • Hostname: berry

From the Raspberry Pi via ssh

Insert the SD card into the Raspberry Pi and power it on.

Wait 10s.

You can now connect from ssh from local network.

1
ssh pi@berry.local

System

1
2
3
4
5
6
sudo rpi-update
sudo apt remove geany chromium-browser thonny dillo realvnc-vnc-server libvncclient1
sudo apt update
sudo apt full-upgrade
sudo apt install vim onboard apt-transport-https cockpit kodi
sudo apt autoremove

Raspberry Pi OS Configuration

1
sudo raspi-config
  • System Options > Boot / Auto Login > B4 Desktop Autologin
  • Localisation Options > Timezone > Europe > Paris
  • Advanced Options > Expand Filesystem

Finish

Users

1
2
3
4
5
6
7
8
9
sudo useradd -m guest
sudo usermod -a -G users guest
sudo usermod -a -G input guest
sudo usermod -a -G plugdev guest
sudo usermod -a -G audio guest
sudo usermod -a -G video guest
sudo -u guest ln -s /mnt/hdd1/Syncthing/Pierre/Videos /home/guest/Videos
sudo -u guest ln -s /mnt/hdd1/Syncthing/Seedbox/Movies /home/guest/Movies
sudo -u guest ln -s /mnt/hdd1/Syncthing/Seedbox/Shows /home/guest/Shows
1
vim /etc/lightdm/lightdm.conf | grep pi

Set autologin-user to guest.

Reboot.

1
ssh pi@berry.local

Shell configuration

1
vim ~/.bash_aliases

Write

1
2
3
alias ll='ls -l'
alias la='ls -al'
alias cll='clear ; ll'

PIXEL Dark Theme

Remove lxappearance-obconf else lxappearance won’t work.

1
sudo apt remove lxappearance-obconf

Menu > Preferences > Main Menu Editor > Preferences > Theme and Preferences Settings

Hard Drive

Source:

Connect your HDD to the Raspberry Pi.

Check the Device name, then the UUID with

1
2
sudo fdisk -l
sudo blkid /dev/sda1

Create mount folder and add fstab entry.

1
2
sudo mkdir /mnt/hdd1
sudo vim /etc/fstab

Add entry.

1
UUID=THE-UUID  /mnt/hdd1  ext4   defaults  0       0

Reboot.

1
sudo reboot

Change access mode, create folders.

1
2
3
4
sudo chown root:root /mnt/hdd1
sudo chmod 755 /mnt/hdd1
sudo mv /home /mnt/hdd1/
sudo ln -s /mnt/hdd1/home /home

Syncthing

Source:

Installation

As pi user

1
2
3
4
5
6
7
8
9
10
11
# Add repo key
curl -s https://syncthing.net/release-key.txt | gpg --dearmor | sudo tee /usr/share/keyrings/syncthing-archive-keyring.gpg >/dev/null
# Add repo
echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt update
# Install syncthing
sudo apt install syncthing
# Run Syncthing to create config file
syncthing
# Remove default folder
rm -rf ~/Sync

Allowing Outside Access to your Syncthing Web Interface

Edit ~/.config/syncthing/config.xml.

In the gui section, change

1
<address>127.0.0.1:8384</address>

by

1
<address>0.0.0.0:8384</address>

to allow access to any address.

Alternatively, if you want to allow access to local address, use the static IP address of the Raspberry Pi (need to be configured).

Setting up Syncthing as a Service (Deprecated)

1
sudo vim /lib/systemd/system/syncthing.service

Write

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
After=network.target

[Service]
User=pi
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
RestartSec=5
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

This service will run as Pi user.

Enable service at boot, then start.

1
2
sudo systemctl enable syncthing
sudo systemctl start syncthing

Using the Raspberry Pi’s Syncthing Web Interface

https://berry.local:8384/


Netlify status