extroot uses external storage as a writable overlay, giving OpenWrt room for packages and persistent data without replacing the router's internal flash. This article follows the OpenWrt documentation from device discovery and partitioning through the post-reboot checks, recovery paths, and advanced options.1
Warning: This procedure touches partitions and filesystems. Back up the configuration, identify the correct
/dev/sdX, and treat thepartedexample below as a destructive command. Never run it unchanged on a disk containing data.
1. What extroot does and where it applies
On many devices, OpenWrt combines a read-only rootfs with writable rootfs_data or ubifs as an overlay. The documentation's conceptual table is:
| Component | Mount point | Compressed | Writable |
|---|---|---|---|
rootfs | /rom | Yes | No |
rootfs_data or ubifs | /overlay, /rom/overlay | No | Yes |
overlay | / | Depends on the filesystem | Yes |
Extroot adds an overlay on USB, SATA, an SD card, or another block device and mounts it during boot. If the external device is removed, the router still has its internal overlay and can fall back to its pre-extroot state.1
Some firmware without an overlay partition in /proc/mtd may ignore fstab configuration; the source describes using / as the mount point in that special case. Do not make that the default—first inspect the actual layout of the model.
2. Preparation
The source assumes that I can reach a shell through SSH or a UART console. LuCI can edit many of these settings, but shell work makes the device name and command output explicit.1
- Devices with at least 8 MiB of flash generally have enough room for the required packages. Devices with 4 MiB or less should use the Custom image path instead of trying to squeeze packages into the current overlay.
- The
blocktooling supportsext2/3/4,f2fs,btrfs,ntfs, andubifs; the documentation says that FAT16/FAT32 cannot be used for extroot. - The example below uses a USB flash drive, one GPT partition, and
ext4. A USB SSD may also needkmod-usb-storage-uas. - If the internal flash is nearly full, remove unnecessary packages first. Install the standard packages:
| |
Find the disk instead of guessing from the example:
| |
Distinguish a disk such as /dev/sda from a partition such as /dev/sda1. Record the output and confirm that the USB device is visible before moving to the destructive step.
3. Partition and format the USB drive
This is the source's GPT-plus-ext4 method:
| |
The parted command erases the partition table on ${DISK}. If the disk is not new or contains data, stop and identify the correct disk. Other supported filesystems are possible, but their formatting commands and packages must change; do not keep mkfs.ext4 while intending to use f2fs or btrfs.
4. Create the extroot mount entry
Before writing fstab, confirm that OpenWrt sees the UUID of ${DEVICE} and the current overlay mount point:
| |
If either command returns nothing, stop and check the device, filesystem module, and block info output. Once the output is correct, use the source's UCI sequence:
| |
${UUID} comes from the external partition and ${MOUNT} from the existing overlay layout. Do not replace /overlay with another path without understanding the firmware's layout.
Keep the original overlay reachable
The source's next method mounts the old overlay at /rwm. This is useful when the original rootfs_data/ubifs must be inspected or its fstab adjusted after the external device owns /overlay:
| |
The old overlay may then be available at /rwm; the corresponding upper-layer fstab is /rwm/upper/etc/config/fstab. Use the layout returned by block info.
5. Transfer the data and apply the change
Temporarily mount the external partition at /mnt, then copy the current overlay with the source's pipeline:
| |
Reboot when the copy is complete:
| |
Do not remove the USB device before the router has completed the reboot. When configuring over Wi-Fi, use Ethernet or a console so a transient disconnect does not interrupt the operation.
6. Verify after reboot
LuCI
- Open System → Mount Points: the USB partition should be mounted as
overlay. - Open System → Software: free overlay space should reflect the external partition.
Command line
The external partition should be mounted at /overlay, while / is an overlayfs using it as the upper layer:
| |
A successful result shows /dev/sda1 mounted at /overlay and the available space for / matching /overlay; device names and values will differ on the real router.
7. Troubleshooting and recovery boundaries
If boot has a problem, inspect block discovery, fstab, and the preinit stage:
| |
UUID mismatch after an upgrade
If the log reports block: extroot: UUID mismatch, mount the partition and remove the two markers named by the source:
| |
Replace /dev/sda1 with the real device. Do not remove files from another partition.
FAT/FAT32 is not supported
vfat and FAT32 do not work for extroot. If a USB drive is preformatted as FAT, reformat it as ext4 after installing e2fsprogs:
| |
This also erases data on /dev/sda1.
The USB device appears too late
If the partition mounts manually but not during boot, the source suggests increasing delay_root, for example to 15 seconds:
| |
Use a delay only when logs and testing indicate that storage becomes ready late; it is not a universal fix.
Pre-25.xx and post-25.xx firmware
For pre-25.xx releases, the older source material includes a way to permit packages larger than the free space in /rom:
| |
This is not a replacement for extroot and should not be applied blindly. For post-25.xx releases, the source points to the expand_root guide; follow the release-appropriate mechanism instead of mixing both.
On very old systems where only an /etc/rc.local workaround works, the source also records:
| |
This is a historical compatibility branch with possible side effects. Prefer standard extroot or the current release's expand_root method.
Extroot on MMC/SD
For a non-USB block device, modules required to make it visible early must be placed in /etc/modules-boot.d. For SDHCI on MT7688/MT7628, the source gives /etc/modules-boot.d/mmc with:
| |
The correct modules depend on the SoC and driver; this is the source's example, not a universal list.
8. Useful additions after extroot
Keep package lists out of RAM
To make package lists survive reboot and reduce RAM use, move the list directory from /var/opkg-lists to /usr/lib/opkg/lists.
In LuCI, open System → Software → Configuration, change lists_dir to /usr/lib/opkg/lists, then open System → Software → Actions → Update lists.
Or run:
| |
Create swap on extroot
If a router with roughly 32 MB of RAM cannot read package lists, the source presents a 100 MiB swap file on extroot:
| |
Swap increases writes to the USB/flash device and does not turn a router into a high-memory server. Use reliable storage, monitor I/O errors, and never put secrets in a swap file.
USB dongles and usb-modeswitch
The source allows adding usb-modeswitch to an image, but warns about dongles combining a CD-ROM, modem, and card reader: if /overlay is on the dongle's memory card, switching modes can make the filesystem disappear. A safer option is a dongle preconfigured to enable the modem/network adapter and card reader at power-on without switching modes on the router.
The source demonstrates inspecting ports with an AT command:
| |
Query port meanings with:
| |
In the source example, 1 is the modem, 2 is PCUI, 3 is DIAG, 16 is NCM, and A2 is the SD card. Do not disable PCUI (2) or you may lock yourself out of the dongle. A sample configuration sequence is:
| |
This applies only to a dongle compatible with that AT command set, not to any modem with similarly named ports. The source lists a pre-configuration example for Huawei E3131s-2 firmware v21.158.47.00.1094.
Remote filesystems
The source only links to a guide for fstab failing to mount CIFS at boot; it does not provide a complete CIFS procedure in this article. I do not turn that reference into a generic mount command. Check credentials, network availability, and boot ordering for the actual model and release.
9. LUKS encrypted extroot: advanced branch
The source says that OpenWrt 22.03 does not support opening LUKS reliably before the extroot check. Before starting, create a LUKS container using the disk-encryption documentation, and make sure rootfs_data has room for cryptsetup and its dependencies. Once the volume is unlocked, follow the extroot procedure inside it and copy the data from /overlay.1
Preferred PREINIT method
The source describes a cleaner method: during PREINIT, mount_root looks for block on ROM/overlay and calls block extroot. A wrapper can therefore open the encrypted device before invoking the real binary.
Do not skip these conditions:
- Install
block-mountandcryptsetup. - Install the executable
decrypt.shscript from the disk-encryption documentation. - Move the real
/sbin/blockbinary to/sbin/block.bin. - Place the wrapper at
/upper/sbin/blockon a UBIFS overlay, or/sbin/blockwhen already on overlayfs, and make it executable. - Use
/.use_crypt_extrooton overlayfs or/upper/.use_crypt_extrooton/overlayas the enable marker. - Set up
/etc/crypttabbefore rebooting.
When the marker is absent, encrypted extroot remains disabled, which provides a way to turn it off from failsafe. The source includes the complete wrapper code, but it changes PREINIT behavior, creates device nodes, and loads kernel crypto modules; it should be checked against the actual kernel rather than copied into another model without review.
Fallback /etc/rc.local method
The source gives a more side-effect-prone alternative: normal boot fails to find extroot, then /etc/rc.local opens LUKS at the end of boot and calls mount_root again. Its keyfile example is /root/extroot.key:
| |
This method does not read an interactive password in /etc/rc.local; the source expects a keyfile and asks the operator to consider the threat model of storing it at /root/extroot.key. The web interface may take another 20–30 seconds to appear, while SSH is not necessarily delayed. Use it only when the PREINIT path fails and a failsafe route is ready.
10. System upgrades and custom images
Do not use opkg upgrade for a blind system upgrade
The source warns against blindly using opkg upgrade on snapshots: the uClibc ABI may change, /rom or /rwm UUIDs may change and break extroot, a kernel/module mismatch can brick the router, and upgrading every package except the kernel/modules can leave packages broken.1
For a stable release, sysupgrade to a coherent image. Afterward, you may need to repeat the mount-entry steps and reinstall packages—especially kernel modules—while checking UUIDs before the next reboot.
Custom image for 4 MiB devices
For routers with 4 MiB or less, the source uses the Image Builder on 64-bit Linux or WSL:
- Download the Image Builder for the correct target.
- Extract it and run:
| |
- Find the correct profile, for example:
| |
- Build an image with the profile and required packages:
| |
- Open
bin/target/<device-type>/generic/, select the matchingfactoryorsysupgradeimage, and install it. - Format the USB drive as ext4 with Linux LiveCD or GParted because, in the source example,
e2fsprogsis too large for a 4 MiB device.
Automated setup and automated upgrade
openwrt-auto-extrootis an Image Builder frontend that can automatically format and configure a plugged-in storage device that has not been set up.- The source's automated-upgrade branch combines Hotplug extras and Opkg extras; packages needed by extroot are stored in the
initprofile and restored after the upgrade. - Its restore script uses
/etc/uci-defaults/90-extroot-restore, checksfstab.extrootand/etc/opkg-restore-init, mounts temporarily, movesetc/upper, then reboots. This is an upgrade pipeline for operators who understand the layout; do not run it on a router without a backup.
Conclusion
Extroot is not just “plug in USB and mount it.” The critical parts are identifying the correct ${DEVICE}, keeping the old overlay reachable through /rwm, copying all data, verifying /overlay after reboot, and preparing recovery for UUID mismatches or late storage discovery. USB mode switching, LUKS, custom images, and automated upgrades each have their own limits; when uncertain, stop at standard extroot and keep the backup outside the router.


Góp Ý / Bình Luận / Đánh giá