Explainer
Read-only root and data partition for edge PC power-fail resilience
Short answer
Yes: give the edge PC a read-only ext4 root with errors=remount-ro, tmpfs or an overlay for paths that must write at runtime, and one ext4 data partition mounted commit=5 with barriers on, while the database keeps fsync=on and synchronous_commit=on. A cut then costs at most one cleanly rolled-back journal interval plus whatever was never flushed, and every acknowledged transaction survives. Managed-flash corruption during an internal program cycle still needs a controlled shutdown or hold-up power.

On this page
Splitting the box into an immutable root and one journaled data partition is the right answer for an edge PC that loses its 24 VDC feed without warning. Mount the root filesystem ext4 with ro,noatime,errors=remount-ro, give every runtime writer a tmpfs or overlay home, and put all persistent writes on a dedicated ext4 partition mounted commit=5 with write barriers on, while the database keeps fsync=on and synchronous_commit=on. After a cut the OS boots exactly as shipped, metadata is consistent up to the last journal commit, and every transaction the database acknowledged is on the media. The one failure no mount option touches is managed flash corrupting itself during an internal program cycle; that case needs a controlled shutdown or hold-up power.
Two failure domains, two countermeasures #
A power cut threatens two different things, and conflating them is why single-mechanism designs fail. System integrity is the root filesystem: the OS, the container runtime binaries, the configuration. Corruption there means a re-flash and lost commissioning time. Application data integrity is the database files and write-ahead logs inside container volumes; corruption there means lost process history and possibly an unrecoverable cluster. The architecture separates them: make the OS immutable so a cut has nothing to tear, and confine all writes to one partition where ext4 journaling and application-level fsync semantics can be reasoned about together. Read-only mounting as the first line of defense is the same move described in Why Industrial Edge Publisher mounts removable storage read only, applied there to removable media and here to the OS partition itself.
| Failure at the moment of the cut | Symptom on power-up | Layer that handles it |
|---|---|---|
| Dirty page cache lost before writeback | Recent writes missing or truncated | Application fsync: PostgreSQL fsync=on |
| ext4 metadata inconsistent | Repair on boot, files in lost+found | ext4 journal, data=ordered minimum, barriers on |
| Torn page inside a database file | Cluster refuses to start, checksum errors | full_page_writes=on, data checksums |
| Writes into OS directories mid-cut | Broken units, corrupt package database, unbootable image | Read-only root, tmpfs or overlay for volatile paths |
| overlay2 layer metadata damaged | Containers fail to start | Runtime storage on the data partition; images re-pullable, volumes are the data |
| eMMC mapping table lost mid-program | Whole device or whole blocks unreadable | Nothing in software: controlled shutdown or hold-up power |
Every row except the last is a software problem with a software answer. The last row is not, and it is handled at the end, because no mount option reaches it.
The mount layout #
Verify the actual partitions on your unit before changing anything, and never copy device numbering from another installation:
lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT
blkid
cat /proc/mounts
The target layout gives the root filesystem zero writes in steady state and one journaled home for everything persistent:
| Mount point | Backing | Mode | Purpose |
|---|---|---|---|
/ |
root partition, ext4 | ro |
immutable OS |
/data |
dedicated ext4 partition | rw, journaled |
runtime storage, database volumes, application logs |
/tmp, /var/tmp |
tmpfs | rw, volatile |
runtime scratch, lost on reboot by design |
/var/log |
tmpfs or a path on /data |
volatile or persistent, your choice | logs |
/etc (only if writes are required) |
OverlayFS, upper on /data |
rw |
persistent configuration deltas without unlocking root |
An example fstab follows. The two UUIDs are examples: read your own from blkid, and address partitions by UUID because eMMC device nodes can re-enumerate across kernel updates.
# example values: take the real UUIDs from blkid on your unit
UUID=6d1f0a44-2c7e-4b9e-9a51-3e0c8b7d5f12 / ext4 ro,noatime,errors=remount-ro 0 1
UUID=9b3e7c21-5d84-4f0a-8e26-7c1d9a4b6e03 /data ext4 rw,noatime,errors=remount-ro,commit=5 0 2
tmpfs /tmp tmpfs rw,nosuid,nodev,mode=1777,size=256M 0 0
tmpfs /var/tmp tmpfs rw,nosuid,nodev,mode=1777,size=128M 0 0
tmpfs /var/log tmpfs rw,nosuid,nodev,mode=0755,size=128M 0 0
What each option is doing:
rokeeps the steady-state write count on the OS partition at zero, so a cut has nothing to tear there.noatimedrops the inode timestamp update on every read; redundant on the read-only root, a real write-amplification cut on the data partition.errors=remount-romakes the kernel drop the filesystem to read-only on detected corruption instead of continuing to write into a damaged structure.commitis the ext4 journal commit interval in seconds; it bounds how much recent metadata a clean rollback can undo, not data the application never flushed.- Barriers are on by default and stay on. They force the ordering between journal commits and data blocks through the device cache; mounting this media
nobarrierfor throughput destroys the durability argument for the whole design. data=ordered, the ext4 default, writes file contents before the metadata that points to them; keep it as the minimum.
Making a read-only root survive real use #
A stock Linux userspace assumes it can write to /var, /etc and /home. Flipping root to ro without redirecting those paths produces subtle failures: services that start but cannot persist state, DHCP leases that vanish, SSH host keys regenerated on every boot.
Inventory the writers before locking anything. Boot normally, run a full application cycle, then list what touched the root filesystem; run it on a working box, not an idle one, or you will miss the writers:
find / -xdev -newermt '-1 hour' -type f 2>/dev/null | grep -v '^/proc\|^/sys'
Send volatile paths to tmpfs with the fstab entries above. For paths whose changes must survive reboot, an OverlayFS keeps the shipped configuration as the read-only lower layer and stores the deltas in an upper directory on the data partition:
mkdir -p /data/overlay/etc/upper /data/overlay/etc/work
mount -t overlay overlay -o lowerdir=/etc,upperdir=/data/overlay/etc/upper,workdir=/data/overlay/etc/work /etc
Two documented OverlayFS requirements apply: the upper and work directories must sit on the same filesystem, and the work directory must be empty at mount time.
Persist SSH host keys and machine-id explicitly; they are the two items that most often break monitoring and certificate trust after a tmpfs conversion.
Keep a maintenance path for updates, gated behind a scripted service so a field technician cannot leave the unit writable:
mount -o remount,rw / # maintenance window
sync
mount -o remount,ro / # relock before leaving
One trap to weigh: an upper layer on the data partition means a corrupted data partition can still break the OS view, defeating part of the immutability goal. If guaranteed bootability is the objective, use tmpfs uppers everywhere except a short, explicitly enumerated list of files that truly must survive reboot.
The whole split assumes a Linux image you control; choosing among images is the subject of Choosing an operating system image for an industrial PC.
Container and database settings #
Relocate the container runtime's storage so no container write lands on root: the daemon's data-root setting goes to /data/docker. Treat images as re-pullable and volumes as the data; both then sit on the data partition, where the journal and the fsync semantics apply. Whether a given database belongs in a named volume or a bind mount is its own trade-off, covered in Docker named volumes or bind mounts for an edge IoT stack; for power-fail resilience what matters is that either lands on the data partition, never in a container's writable layer.
The database then has to do its part, and for PostgreSQL that means three settings: fsync=on, so WAL flushes actually reach the media; synchronous_commit=on, so the commit reply waits for that flush; and full_page_writes=on, so whole page images land in the WAL and a torn page can be rebuilt. Data checksums are chosen when the cluster is initialized; decide that before the first production start, not after.
Worked example: the 5 s journal window on the data partition #
The case: the data partition as configured above, a database committing synchronously, and a cut at the worst possible instant.
Inputs, with sources:
- Journal commit interval on the data partition: 5 s, from the
commit=5chosen in the mount layout above. - Database durability:
fsync=onandsynchronous_commit=onfrom the previous section, so a commit is acknowledged only after its WAL record is flushed. - Unit conversions: 60 s in a minute, 3600 s in an hour, 86,400 s in a day.
The rule, in words: ext4 commits its journal once per interval. After a cut, everything up to the last committed journal transaction is consistent; anything inside the partial interval is rolled back cleanly. A transaction the database acknowledged was flushed before its acknowledgment, so it never sits inside the window. Writes the application never flushed are outside the journal's promise altogether, and no commit interval bounds them.
The arithmetic: 60 s ÷ 5 s = 12 journal commits a minute; 3600 s ÷ 5 s = 720 in an hour; 86,400 s ÷ 5 s = 17,280 in a day.
The result, for a cut at any instant:
- Acknowledged transactions lost: none, with barriers on and a media that honors flushes.
- Metadata: at most one commit interval, rolled back cleanly, no repair needed.
- Unflushed writes: whatever the application had buffered, which is the application's exposure, not the filesystem's.
The decision: keep commit=5. 720 commits in an hour is light traffic for managed flash, and a shorter interval multiplies it while protecting nothing the database has not already flushed. If power-cut testing on your unit ever shows torn file contents instead of clean rollbacks, escalate to data=journal and accept the write-volume cost.
The limit no mount option fixes #
Managed flash such as eMMC or SD runs internal garbage collection and mapping-table updates that Linux cannot see. If power disappears during one of those internal program cycles, the mapping itself can corrupt: whole blocks or the whole device unreadable, every partition at once. The damage sits below every filesystem, so it sits below every countermeasure in this article. On flash-backed edge boxes it typically surfaces later as container runtime failures, the case traced in Docker OCI runtime create failed on SD card storage.
Two engineering answers remain, and you want at least one of them:
- Hold-up power that carries the box through a
syncand an orderly shutdown when the feed drops: a buffered supply or a small UPS with a shutdown signal into the PC. - A controlled-shutdown path: power-fail detection wired to the OS so the databases stop and the filesystems are synced before the hold-up is exhausted.
If losing this box would stop a line or blind a quality decision, treat that shutdown path as part of the design, not an accessory; no mount option substitutes for it. With images re-pullable and volumes on the journaled partition, the recovery story is then complete: the OS boots as shipped, the data replays to the last journal commit plus every acknowledged transaction, and the only unrecoverable case is the one the hold-up power was there to prevent.
Questions asked
When is data=journal worth its cost on the data partition?
Only when repeated power-cut testing shows torn file contents that page checksums and full_page_writes cannot heal. The mode journals file contents as well as metadata, roughly doubling the write volume on flash and disabling direct I/O, so treat it as an escalation for a demonstrated failure rather than a default.
Why keep synchronous_commit on if it slows every insert?
Turning it off lets the WAL flush lag behind the commit reply, so a cut inside that lag erases transactions the application believes were saved: phantom commits on a historian. With fsync=on and synchronous_commit=on the reply waits for the flush, which is what keeps acknowledged history outside the journal window. If commit rate matters, batch transactions in the application instead of weakening the guarantee.
What has to watch a data partition mounted with errors=remount-ro?
A supervision task that reads the mount state and alarms when the partition flips read-only. The failure is quiet: the box keeps running, clients keep connecting, but every write fails, so without that alarm the plant loses history while everything looks healthy. Alert on the remount, then repair or reimage the partition before returning it to service.
Will the vendor's firmware update still work on a read-only root?
Confirm it before deployment. An update mechanism that expects a writable root fails or rolls back when root is mounted ro, so verify with the vendor that a read-only root and a custom data partition survive the shipped image's update process, and repeat that check after every update. Where it does not, apply updates from the maintenance remount and relock immediately afterwards.


