Skip to content

Commit

Permalink
Remove read-only option and rename scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zbchristian committed Apr 22, 2021
1 parent 0258a34 commit c36e7ba
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 108 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $ ./install_raspap_ro_wlan.sh
Follow the instructions.

## Configure Raspian, install drivers and start the RaspAP installer
The script `install_raspap_ro_wlan.sh` configures Raspian for a (nearly) read-only operation (see below), allows to install additional Wifi driver modules and starts the RaspAP installer ( https://install.raspap.com ). See details about the Raspian configuration and driver installation below.
The script `install_raspap_ram_wlan.sh` configures Raspian for a (nearly) read-only operation, allows to install additional Wifi driver modules and starts the RaspAP installer ( https://install.raspap.com ). See details about the Raspian configuration and driver installation below.

## Install missing WLAN driver modules
A standard nuisance of Raspian is, that drivers for a lot of WLAN devices are missing. This is especially true for Realtek based devices.
Expand All @@ -20,15 +20,10 @@ The webpage http://downloads.fars-robotics.net by MrEngman provides a lot of pre
If you prefer to compile drivers from scratch, the script `install_wlan_drivers_8812au_88x2bu.sh` extracts the source for two very common drivers (Realtek 8812au and 88x2bu) from Github. The source is compiled and the installation done via DKMS. This ensures, that the driver is automatically recompiled, when the kernel version is changing.
Depending on the raspberry pi version, this can take a long time.

## Raspian with substantially reduced SD-Card access
## Raspian with substantially reduced SD-Card write access
Utilizing a Raspberry PI as an access point, requires a reliable operation over a long period of time. Switching the Raspberry PI off without a regular shutdown procedure might lead to a damaged system. Writing lots of logging and temporary data to the SD-card will shorten the lifetime of the system.

Moving logging and temporary data to a RAM based files system can minimize the risk and extend the lifetime of the SD-card substantially.

The script `raspian_readonly.sh` will replaces the default logging service, moves temporary file locations to RAM and switches off the file system check and swap in `/boot/config.txt`. By default the file system is still in read/write mode, so RaspAP settings can be saved.
The script `raspian_min_write.sh` replaces the default logging service, moves temporary file locations to RAM and switches off the file system check and swap in `/boot/config.txt`. By default the file system is still in read/write mode, so RaspAP settings can be saved.
The remaing access to the SD-card can be checked with the tool `iotop -aoP`.

## Read-only Raspian
For a fully read-only system, start the script with the read-only option: `raspian_readonly.sh -ro`
Be aware, that this might render your system unusable. Check the log files (`journalctl`) for error messages.
In order to write changes to the system, you can remount the file system with the command `rw`, which is placed into `.bashrc`. Remounting to read-only is achieved by the command `ro`.
10 changes: 5 additions & 5 deletions install_raspap_ro_wlan.sh → install_raspap_ram_wlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# - Write Raspian lite to a SD-card
# - Create a file with name "ssh" (no extension) on the partition called "boot", to allow for SSH access
# - start the Raspberry PI with the SD-Card and login via ssh (default user: pi, password: raspberry)
# - download this script: "wget https://raw.githubusercontent.com/zbchristian/raspap-tools/main/install_raspap_ro_wlan.sh"
# - chmod +x install_raspap_ro_wlan.sh
# - ./install_raspap_ro_wlan.sh
# - download this script: "wget https://raw.githubusercontent.com/zbchristian/raspap-tools/main/install_raspap_ram_wlan.sh"
# - chmod +x install_raspap_ram_wlan.sh
# - ./install_raspap_ram_wlan.sh
#

RED="\e[31m\e[1m"
Expand All @@ -21,8 +21,8 @@ function _echo() {
}

function _RAMVersion() {
wget -q https://raw.githubusercontent.com/zbchristian/raspap-tools/main/raspian_readonly.sh -O /tmp/raspian_readonly.sh
source /tmp/raspian_readonly.sh
wget -q https://raw.githubusercontent.com/zbchristian/raspap-tools/main/raspian_min_write.sh -O /tmp/raspian_min_write.sh
source /tmp/raspian_min_write.sh
}

function _installWifiDrivers() {
Expand Down
54 changes: 54 additions & 0 deletions raspian_min_write.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# RASPBERRY PI: limit the sd-card write operation to a minimum by moving temporary and log files to RAM
# - Write access can be checked with "iotop -aoP"
# - Remaining access originates mainly from the ext4 journal update (process jbd2)
#
# tested with Raspian lite Buster
# zbchristian 2020

function _dirs2tmpfs() {
for dir in "${dirs[@]}"; do
echo "Move $dir to RAM"
if ! grep -q " $dir " /etc/fstab; then
echo "tmpfs $dir tmpfs nosuid,nodev 0 0" | sudo tee -a /etc/fstab
fi
done
}

RED="\e[31m\e[1m"
GREEN="\e[32m\e[1m"
DEF="\e[0m"

echo -e "${GREEN}\n\nModify System to minimize the Write Access to the SD-Card${DEF}\n"

echo -e "${GREEN}Remove some packages ...${DEF}"

sudo apt -y remove --purge triggerhappy dphys-swapfile logrotate
sudo apt -y autoremove --purge

echo -e "${GREEN}Disable services ...${DEF}"

sudo systemctl unmask bootlogd.service
sudo systemctl disable bootlogs
sudo systemctl disable console-setup
sudo systemctl disable apt-daily.service apt-daily.timer apt-daily-upgrade.timer apt-daily-upgrade.service

echo -e "${GREEN}Install new logger ...${DEF}"
sudo apt-get -y install busybox-syslogd
sudo dpkg --purge rsyslog

echo -e "${GREEN}Modify boot options to switch off swap and file system check ...${DEF}"
# disable swap
if ! grep -q "noswap" /boot/cmdline.txt; then
sudo sed -i '1 s/$/ fsck.mode=skip noswap/' /boot/cmdline.txt
fi

echo -e "${GREEN}Add tmpfs entries to /etc/fstab ...${DEF}"
# move directories to RAM
dirs=( "/tmp" "/var/log" "/var/tmp" "/var/lib/misc" "/var/cache")
# special dirs used by vnstat and php
dirs+=( "/var/lib/vnstat" "/var/php/sessions" )
_dirs2tmpfs

echo -e "${RED}You should reboot now ...${DEF}"

95 changes: 0 additions & 95 deletions raspian_readonly.sh

This file was deleted.

0 comments on commit c36e7ba

Please sign in to comment.