Skip to content

Lesson 3 of 9 · 23m

opkg, Overlay Storage, and Upgrade Hygiene

Manage packages, understand the overlay filesystem, preserve configuration, and upgrade OpenWrt without turning small storage into a reliability incident.

A router feels stateless until you realize your firewall rules, wireless credentials, static leases, certificates, and package customizations all live in a few megabytes of flash. OpenWrt's power comes from treating that tiny system as mutable infrastructure. Its fragility comes from the same place. Package management and upgrades are capacity planning exercises.

The filesystem model controls everything

Most flash-based systems combine a read-only squashfs root with a writable overlay:

/rom       original compressed system files
/overlay   your changes and package payloads
/          union view presented by overlayfs

Inspect it before installing anything ambitious:

df -h /
df -h /overlay
mount | grep overlay

Deleting a file that exists in /rom often creates a whiteout in the overlay rather than freeing flash. Removing stock files can consume space, not return it.

opkg is not a bottomless repository

Update indexes before installing packages, then install with restraint:

opkg update
opkg list-installed | grep '^luci'
opkg install wireguard-tools tcpdump

Useful small tools include tcpdump, mtr-nojson, iperf3, wireguard-tools, and ca-certificates. Avoid desktop Linux habits. A compiler, full Python environment, monitoring agent, and three overlapping DNS resolvers can consume the overlay faster than any firewall mistake.

Know what sysupgrade preserves

A normal upgrade keeps whitelisted configuration files and replaces the base system:

sysupgrade -l | sort | less
sysupgrade -b /tmp/backup-$(date +%F).tar.gz
sysupgrade -v /tmp/openwrt-device-squashfs-sysupgrade.bin

Copy the backup off-box before upgrading. Installed packages are not immortal; kernel ABI expectations and repositories change across releases. Maintain a package list:

opkg list-installed | awk '{print $1}' | sort > /etc/opkg-installed.txt

Better yet, use attended sysupgrade or the firmware selector to build an image with your package set included. Baking packages into squashfs is often more space-efficient than layering them afterward.

Upgrade like it is production, because it is

A practical ritual is: export backup and package list, read release notes, verify the checksum, upgrade in a maintenance window, then verify boot, LAN, WAN, wireless, firewall, DNS, and DHCP. Configuration belongs in version control or encrypted backup, but do not blindly copy raw files between hardware; MAC addresses, radio paths, switch topology, and interface order are device-specific.

Field notes

  • /tmp is RAM-backed; large images vanish on reboot and consume memory while present.
  • Uncontrolled logging wears flash faster than ordinary configuration edits.
  • A full overlay can make package dependency resolution fail halfway through.
  • Do not mix package versions across release lines because they happen to install.
  • If a service matters enough to configure, test it after sysupgrade and after reboot.

Was this lesson helpful?

Sign in to rate