Skip to main content Link Search Menu Expand Document (external link)

Raspberry Pi OS

Standard configuration

Install

  1. Download image here
  2. Enable SSH by placing a ssh file in the boot partition
  3. Create userconf.txt in the boot partition containing username:password, generated using echo 'MYPASSWORD' | openssl passwd -6 -stdin. On Windows, you can use the Git Bash.
  4. Boot
  5. Change root password with sudo passwd
  6. Config with sudo raspi-config
  7. Change swap size if needed - Source
    1. Stop swap sudo dphys-swapfile swapoff
    2. Edit sudo nano /etc/dphys-swapfile and change CONF_SWAPSIZE=100
    3. Setup new swap sudo dphys-swapfile setup
    4. Start swap sudo dphys-swapfile swapon
    5. Reboot

Check also common Linux setup in the Linux page!

Manage IP address / DHCP

  1. Edit sudo nano /etc/dhcpcd.conf
  2. At the bottom, uncomment and change interface eth0 and following
  3. If you want to use Cloudflare DNS: static domain_name_servers=1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001

Overclock

  1. CPU: in raspi-config
  2. SD card:
    • sudo bash -c 'printf "dtoverlay=sdhost,overclock_50=100\n" >> /boot/config.txt' - Source
    • sudo cat /sys/kernel/debug/mmc0/ios to check the clock

Date & Time

Raspberry OS manage time with timedatectl:

  • Show existing date & time: date
  • Show status timedatectl status
  • Enable NTP timedatectl set-ntp True then restart the NTP service sudo systemctl restart systemd-timesyncd.service

Software install

Docker

  1. Download docker install script curl -sSL https://get.docker.com >> docker.sh
  2. Run the script sh ./docker.sh
  3. Add pi user to docker group sudo usermod -aG docker pi
  4. Log-out and log-in

Duplicati

Install on Raspberry Pi OS

  1. Install Mono Framework sudo apt install mono-complete ca-certificates-mono
  2. Sync certificates sudo cert-sync /etc/ssl/certs/ca-certificates.crt
  3. wget the download .deb. from the Duplicati website
  4. Install sudo apt install ./duplicati*.deb or sudo dpkg -i duplicati*.deb
  5. Check for additional missing dependencies sudo apt -f install
  6. Allow Duplicati in the firewall sudo ufw allow 8200
  7. Set up Duplicati as a service
    1. Edit new file sudo nano /etc/systemd/system/duplicati.service
    2. Copy-paste the service file content:
       [Unit]
       Description=Duplicati
       After=network.target
      
       [Service]
       Nice=19
       IOSchedulingClass=idle
       EnvironmentFile=-/etc/default/duplicati
       ExecStart=/usr/bin/duplicati-server $DAEMON_OPTS
       Restart=always
      
       [Install]
       WantedBy=multi-user.target
      
    3. Edit file sudo nano /etc/default/duplicati
    4. Replace the last line of the initscript content: DAEMON_OPTS="--webservice-interface=any --webservice-port=8200 --portable-mode"
    5. Enable and start the Duplicati service
       sudo systemctl enable duplicati.service
       sudo systemctl daemon-reload
       sudo systemctl start duplicati.service	
       sudo systemctl status duplicati.service
      
  8. If wished, set-up system-wide backup:
    • Source data: /etc, /home, /root, /var excluding /var/lock/, /var/run and Temporary file
    • Options: zip-compression-level: 1 - default on Linux is 6, but this slow down the Raspberry Pi
    • If only upload, in order to help the Raspberry Pi
      • asynchronous-concurrent-upload-limit:1
      • asynchronous-upload-limit:1

Sources:

Samba - Windows Share

  1. Install it sudo apt install samba samba-common-bin
  2. Create a share on root directory sudo mkdir -m 1777 /share
    • 1 is sticky bit
    • 777 is everyone permission to r/w/e
  3. Edit samba configuration sudo nano /etc/samba/smb.conf
    • Add at the bottom of the file
        [share]
        Comment = share
        Path = /share
        Browseable = yes
        Writeable = Yes
        guest only = no
        create mask = 0777
        directory mask = 0777
        valid users = joe, greg
      
    • This set up a r/w share only for joe and greg users
    • Check all options here
  4. Add a user
    1. Create a new UNIX user sudo adduser joe
    2. Add user to samba sudo smbpasswd -a joe
  5. Add samba to ufw exception, if you have it sudo ufw allow Samba
  6. Restart samba sudo samba restart

Create an Access Point

From this guide:

  1. Install dependencies:

     sudo apt install hostapd
     sudo systemctl unmask hostapd
     sudo systemctl enable hostapd
     sudo apt install dnsmasq
     sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent
    
  2. Edit sudo nano /etc/dhcpcd.conf:

     interface wlan0
         static ip_address=192.168.4.1/24
         static routers=192.168.4.1
         static domain_name_servers=1.1.1.2 1.0.0.2
         nohook wpa_supplicant
    
  3. Edit sudo nano /etc/sysctl.d/routed-ap.conf and/or in /etc/sysctl.conf:

     # Enable IPv4 routing
     net.ipv4.ip_forward=1
    
  4. Update iptables

     sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
     sudo netfilter-persistent save
    
  5. Configure dnsmasq

    1. Copy the original file sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
    2. Edit sudo nano /etc/dnsmasq.conf

      conf interface=wlan0 # Listening interface dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h # Pool of IP addresses served via DHCP domain=wlan # Local wireless DNS domain address=/gw.wlan/192.168.4.1 # Alias for this router conf

  6. sudo rfkill unblock wlan

  7. Change below to your liking and update sudo nano /etc/hostapd/hostapd.conf

     country_code=GB
     interface=wlan0
     ssid=NameOfNetwork
     hw_mode=g #g = 2.4 GHz, a = 5 GHz
     channel=7
     macaddr_acl=0
     auth_algs=1
     ignore_broadcast_ssid=0
     wpa=2
     wpa_passphrase=AardvarkBadgerHedgehog
     wpa_key_mgmt=WPA-PSK
     wpa_pairwise=TKIP
     rsn_pairwise=CCMP
    
  8. sudo reboot and enjoy!

For some troubleshooting help:

  • Check sudo systemctl status hostapd.service, wpa_supplicant.service and dnsmasq.service if you have troubles
  • If error with hostapd: unmask the service, or rfkill unblock wlan and then rfkill list wlan to check
  • If error with dnsmasq.service::
    • Check configuration sudo nano /etc/dnsmasq.conf, last line should look like dhcp-option=6,1.1.1.2,1.0.0.2 and not have a , at the end
    • If DHCP packet received on wlan0 which has no address, check ifconfig and try to manually set the IP sudo ifconfig wlan0 192.168.4.1
  • If no internet on device, try to reapply firewall setting: sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE