Why Raspberry Pi SD Cards Corrupt in School Labs (and the Fix)

Sudden power cuts from load shedding and pulled power cables corrupt SD cards by interrupting mid-flight flash writes. A built-in read-only overlay fixes it completely without buying a UPS.
Raspberry Pi SD cards corrupt in school labs because standard operating systems expect a controlled shutdown, while classroom environments deliver sudden power cuts. When load shedding drops the mains supply or a learner yanks a USB-C power lead to pack up their bag, power vanishes midway through writing metadata or log files to flash memory. The solution does not require buying forty uninterrupted power supplies (UPSs); it requires enabling the read-only overlay filesystem already built into Raspberry Pi OS.
The Anatomy of a Corrupted MicroSD Card
A standard Raspberry Pi OS installation splits the microSD card into two main partitions: a small FAT32 partition mounted at /boot (or /boot/firmware on newer releases) containing firmware and kernel files, and a larger ext4 partition mounted at / containing the operating system, applications, and user directories.
Both partitions fail under sudden power removal, but for different technical reasons:
- The un-journalled FAT32 partition: FAT32 maintains a File Allocation Table that tracks which storage clusters belong to which file. It does not use a journal. If the Pi loses power while writing to
config.txtor updating an EEPROM image, the allocation table is left in an inconsistent state. The next boot halts before the Linux kernel even starts. - The ext4 journal and write-amplification: While
ext4is a modern, robust journaling filesystem, the physical medium underneath it is a consumer microSD card. SD cards use inexpensive NAND flash managed by a rudimentary microcontroller. When the operating system writes a tiny 4KB log entry (such assystemdlogging learner logins), the SD card’s internal controller must read, erase, and rewrite an entire NAND erase block, which can be several megabytes in size. If power cuts during that internal erase-write cycle, the entire block is damaged. Even if the ext4 journal attempts to replay transactions on reboot, it cannot repair physically corrupted flash blocks.
In a school lab with thirty machines, constant system logging, temporary browser caches, and periodic background package updates mean that at any given second, several cards are actively writing data. Multiply that across daily periods and frequent municipal power cuts, and lab managers end up re-flashing multiple cards every week.
The Permanent Fix: The Read-Only Overlay Filesystem
The cleanest, zero-cost fix is an overlay filesystem (OverlayFS). Instead of writing directly to the microSD card, the Linux kernel mounts the physical SD card as strictly read-only. It then places a temporary, virtual filesystem running in volatile RAM on top of it.
From the learner’s perspective, the computer works normally: files can be created, Python scripts executed, and desktop settings adjusted. But those writes exist solely in RAM. The physical SD card never experiences a write cycle. When power is abruptly disconnected—whether by an unplanned Stage 4 outage or a kicked multi-plug—no write operation is interrupted. Upon reboot, the system returns instantly to the exact clean state established when the overlay was configured.
Step-by-Step Configuration via raspi-config
You do not need to install third-party scripts. Raspberry Pi OS ships with an overlay tool built into its configuration utility. Follow these exact steps on a master installation before imaging your lab:
- Complete all updates and software installation first: Ensure all required software (IDEs, desktop environments, educational tools) is installed, updated, and configured with the overlay turned off. Once the card is read-only, changes do not persist across reboots. Run:
sudo apt update && sudo apt full-upgrade -y - Launch the configuration utility:
sudo raspi-config - Navigate to the overlay menu: Select Performance Options (or Advanced Options on older OS releases), then select Overlay File System.
- Enable the overlay: When prompted with "Would you like the overlay file system to be enabled?", select Yes.
- Protect the boot partition: When prompted with "Would you like the boot partition to be write-protected?", select Yes. This remounts the fragile FAT32 partition as read-only.
- Reboot the Pi: Exit the utility and allow the system to reboot.
To verify the setup after reboot, open a terminal and run:
df -hIf successful, the root filesystem (/) will show overlay listed as the filesystem type, mounted on a virtual memory device rather than /dev/mmcblk0p2.
How to Update or Modify the System Later
Because the disk is read-only, running apt install or saving administrative settings while the overlay is active will vanish the moment the machine is restarted. When you need to install new packages or change configuration settings:
- Run
sudo raspi-config. - Navigate to Performance Options > Overlay File System.
- Select No to disable the overlay filesystem.
- Select No when asked if the boot partition should remain write-protected.
- Reboot the Pi.
- Perform your administrative maintenance, software updates, or network configurations.
- Run
sudo raspi-configagain to re-enable both the overlay and the write-protected boot partition, then reboot.
Handling Learner Work and File Persistence
The obvious trade-off of a read-only root system is persistence: when learners log off or the machine reboots, their files disappear from the desktop and home directories.
For a school lab, this is often a feature rather than a bug—it prevents students from cluttering machines with downloaded media, game binaries, or broken system configurations. However, learners still need to save their work across lessons. There are two robust ways to handle persistence alongside a read-only operating system:
- External USB thumb drives: Keep the internal microSD card locked down, but allow learners to mount their own USB drives or dedicated school-issued flash sticks formatted as FAT32 or exFAT. These mount independently under
/media/and retain their writes. - Browser-based and network storage: If the lab has network access, direct learners to store code in central repositories, cloud storage, or an integrated learning platform such as Sheen Canvas, ensuring student projects are decoupled from the physical hardware entirely.
For schools designing or upgrading dedicated computer labs, configuring storage resilience is just as critical as choosing the single-board computers themselves. If you need assistance specifying ruggedised enclosures, robust power delivery, or pre-configured lab images, Sheen Robotics provides complete equipment planning through our lab sourcing service.
Power instability is a daily reality in South African classrooms. Configuring Raspberry Pi installations as read-only overlays removes the fragile consumer characteristics of microSD storage, eliminating the cycle of re-flashing cards and ensuring equipment starts reliably at the start of every class period.



