OPENWRT

OpenWrt
OpenWrt Filesystem Overview
In the OpenWrt system, the Overlay partition is a core component that ensures both system flexibility and stability.
Key Mechanism: Union Mount
It utilizes union mount technology to merge two distinct layers:
- Read-only Filesystem: The original firmware state.
- Writable Filesystem: Where user changes and configurations are stored.
By combining these into a single logical view, the system allows for easy modifications while maintaining a “factory reset” capability.
I. Core Functions of Overlay
1. Differential Storage and Configuration Persistence
- Read-Only Layer (SquashFS): Stores core system files (kernel, base packages). These are immutable, preventing accidental operations from compromising system stability.
- Writable Layer (Overlay): All user modifications—such as plugin installations and configuration changes—are stored here. This layer stacks with the read-only layer to create a “virtual read-write” view.
2. Rapid System Recovery
- Reset Capability: The system can be restored to factory settings simply by clearing the Overlay partition, eliminating the need for a full firmware re-flash.
- Fault Isolation: Even if the data in the Overlay partition becomes corrupted, the read-only layer ensures the system remains in a basic, bootable state.
3. Flexible Capacity Expansion
- Space Extension: Default onboard Flash memory is often limited (e.g., 128MB). By mounting external storage (USB drives/SD cards) as an External Overlay, the available space for software installation can be significantly increased.
4. Extending Storage Lifespan
- Write Cycle Reduction: By concentrating frequent write operations onto external storage or specific writable layers, the wear and tear on the motherboard’s onboard Flash (which has limited write cycles) is effectively minimized.
II. Specific Steps for Migration/Expansion Using tar
When preparing to mount the Overlay to an external device, a complete replication of existing data is mandatory. Using a tar pipeline is the most reliable method to preserve Linux file permissions, ownership, and symbolic links.
1. Prerequisites
- Ensure the target device is formatted as ext4 (the filesystem with the most robust support for Linux permissions).
- Verify that the necessary packages are installed:
opkg update && opkg install block-mount kmod-fs-ext4
2. Executing the Copy Command
Pay close attention to the target paths to ensure data is correctly extracted to the root of the destination drive:
1 | # 1. Create a temporary mount point and mount the new partition |
Third-party plugins
1. Repository Optimization
- Update the default package repositories to a local mirror (e.g., TUNA or Aliyun) to improve download speeds.
2. Storage & Partitioning
- Overlay Expansion: Install
block-mount,fdisk, andcfdiskto expand the default Overlay partition using external storage (Extroot).
3. Container Virtualization
- Install
luci-app-dockermanto manage Docker containers via the LuCI web interface.
4. Dynamic DNS (DDNS)
- Install
luci-app-ddnsandddns-scripts-dnspod-v3for automated DNSPod domain updates.
5. System Statistics & Monitoring
- Install
luci-app-statisticsandcollectd-mod-sensorsto monitor system temperature and hardware performance metrics.
6. NFS Client Support
- Install
nfs-utils,kmod-fs-nfs,kmod-fs-nfs-common, andkmod-fs-nfs-v4to enable mounting of remote network shares.
7. Development & Remote Access
- Install
git,ssh-keygen, andopenssh-clientfor version control and secure remote connectivity.
8. NFS Server Support
- Install
nfs-serverto allow the OpenWrt device to share its local storage with other devices on the network.
Implementation Guide
1. One-Liner Installation Command
Run the following commands in your SSH terminal to install all components at once:
1 | # Update package database |