extroot overlay
Mainly, I flash the default ext4 openwrt system and then I add a third ext4 partition of the rest of the uSD (or eMMC) and will copy rootfs to it...
The the default rootfs will be used only at bootup and the pivot to extroot overlay will bring the default rootfs readonly...and can be checked and repaired... automagically !
here we go... we add the third ext4 partition
root@OWRT-DEV:/# fdisk /dev/mmcblk0
n
p
3
...
...
w
q
we make it ext4 and format it...
root@OWRT-DEV:/# mkfs.ext4 /dev/mmcblk0p3
we will then add the fstab package (block-mount)
root@OWRT-DEV:/# opkg install block-mount
We create fstab with our filesystems :
root@OWRT-DEV:/# block detect > /etc/config/fstab
We modify fstab with our configuration:
root@OWRT-DEV:/# vi /etc/config/fstab
config mount
option enabled '1'
option enabled_fsck '1'
option target '/'
option device '/dev/mmcblk0p3'
we enable block-mount
root@OWRT-DEV:/# /etc/init.d/fstab enable
then we copy the rootfs filesystems to this third partition clone...
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
mkdir /tmp/mmcblk0p3
mount /dev/mmcblk0p3 /tmp/mmcblk0p3
tar -C /tmp/cproot -cvf - . | tar -C /tmp/mmcblk0p3 -xf -
umount /tmp/cproot
rmdir /tmp/cproot
umount /tmp/mmcblk0p3
rmdir /tmp/mmcblk0p3
we look at the mounted filestysems
root@OWRT-DEV:/# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 252.0M 11.8M 235.0M 5% /
tmpfs 499.5M 432.0K 499.1M 0% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
after a reboot, we will check again :
root@OWRT-DEV:/# reboot
...
/dev/mmcblk0p3: clean, 1341/224448 files, 36986/896256 blocks
[ 8.408467] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts:
[ 8.418665] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 8.429790] mount_root: switched to extroot
...
root@OWRT-DEV:/# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 252.0M 11.8M 235.0M 5% /rom
tmpfs 499.5M 68.0K 499.4M 0% /tmp
/dev/mmcblk0p3 3.3G 25.4M 3.1G 1% /
tmpfs 512.0K 0 512.0K 0% /dev
Now we can add all needed software, and have also a more stable power-fault espressobin !
Hope this helps...