OpenWrt Forum Archive

Topic: How to overlay two read-only ext4 filesystems

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am customzing OpenWRT to run on a Gateworks Ventana 5220, and am booting of a micro-SD card. I would like to overlay two separate partitions that are both mounted read-only as the root partition, but haven't had much luck.

My troubles include:
1) OpenWRT overrides the kernel command line, and always mounts the root partition as rw
2) Despite editing /etc/config/fstab to mount the secondary partition on target /overlay, it doesn't get overlayed with the rootfs

For problem 1, i'm successfully passing in the ro option to the kernel command line, but mount shows the root filesystem as rw. How do I go about configuring a ro ext4 root partion?

# cat /proc/cmdline
console=ttymxc1,115200 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait ro
# mount
/dev/root on / type ext4 (rw,noatime,data=ordered)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

For problem 2, I've edited my /etc/config/fstab as follows, and I see the /overlay directory is being mounted. However, the contents of /overlay are not showing  up under /. How do i configure openwrt to overlay the two partitions as root?

# cat /etc/config/fstab
config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '5'
        option  check_fs        '0'

config 'mount'
        option  target  '/mnt/mmcblk0p1'
        option  uuid    '47f4cc43-be14-41a5-9b0b-9a65d5b14727'
        option  enabled '0'

config 'mount'
        option  target  '/mnt/mmcblk0p2'
        option  uuid    'd88ac5b2-30ea-4202-add6-96627c183fa6'
        option  enabled '0'

config 'mount'
        option  device  '/dev/mmcblk0p3'
        option  target  '/overlay'
        option  enabled '1'

config 'mount'
        option  target  '/mnt/mmcblk0p5'
        option  uuid    '87181c52-ce63-4cbc-b89d-1d732bd8744e'
        option  enabled '0'

config 'mount'
        option  target  '/mnt/mmcblk0p6'
        option  uuid    '2f3b58c7-502f-4218-9adf-5d190febe7f0'
        option  enabled '0'

local directory exists on the overlay but not on root.

# ls /overlay/usr/
local
# ls /usr/
bin    lib    sbin   share

Thanks for the help!

IIRC look here

/lib/functions/preinit.sh

Looking through the preinit scripts, libfstools, and re-reviewing the wiki pages on extroot and preinit indicates openwrt doesn't support this outside of squashfs/jffs2 filesystems. There is a lot of decisions built into the initialization process that assumes flash memory is used for the booting disk.

Looks like I'll be doing some heavy customization. Thanks!

The discussion might have continued from here.