Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Latest commit

 

History

History

Linux

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

RPi-SenseStation OS(Linux) Setup

Operating System

  • Ubuntu Server 22.04 arm64
    • Daily prebuilted image(20221008) for Raspberry Pi ARM64

Packages installed

via APT

  • podman to run/manage Home Assistant container
    • Can be replaced with docker or other OCI-compliant runtimes

Security hardening

Firewall

  • Use Ubuntu's default firewall, UFW
# Enable UFW, this will reject all of incoming connections by default if there's no allow rules
$ sudo ufw enable

# Allow SSH connection only from local network, change `192.168.0.0/24` with your local network IP range
$ sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22

Automatically reboot on kernel panic

# Reboot automatically when kernel panic, after 10 seconds
$ echo "kernel.panic = 10" | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

USB Boot Troubleshoots

  • If your Raspberry Pi does not boot from your USB drive, plug the drive to USB port right next to ethernet port. (ref)
    • In my case, left-top USB port doesn't work but left-bottom USB port works for me.

Reducing writes on microSD card (if you using it)

F2FS

You can skip this section, and I strongly recommend to skip this if you are not familiar with Linux

I just wanted to use flash-friendly file system to get most out of microSD card (and to hope it won't mess up microSD card), so I followed some instructions from WhiteHorsePlanet and addendum from Reddit to convert root filesystem from ext4 to f2fs.

If you want to try it, follow some guides above BUT you should:

  • Complete first boot right after flashing not modified prebuilt image
  • Make sure you installed f2fs-tools before shutdown
    # On RPi
    $ sudo apt install f2fs-tools
    $ sudo shutdown 0
  • Make sure you formatted new filesystem labelled as writable
    # On another Linux host
    $ sudo mkfs.f2fs -l writable /dev/sdX
  • When you edit fstab file, you should REMOVE errors=remount-ro MOUNT OPTION or Ubuntu will not mount root filesystem as read/write!
    errors=remount-ro mount option is not exist in F2FS, so Ubuntu will cause some errors and eventually will mount root filesystem as read-only.
    If the mount option not exists, you can just continue.
  • It is recommended to add noatime,nodiratime mount option to root filesystem in fstab, even on ext4 and/or HDD. This options will prevent kernel to record access time of each files/directories, so write operations will be reduced.

This will help reducing microSD card writes by mounting logs(/var/log) to RAM.
Just follow instruction in Log2Ram README.md to install.

If Log2Ram's systemd service fails after reboot, just manually start by command($ sudo systemctl start log2ram) and reboot again.