I am trying to figure out how to setup a tmpfs overlay mounted to /
. This would be on top of the ubifs overlay mounted to /
. The contents stored in the tmpfs overlay need to not survive a reboot.
The goal here is to be able to tweak things on the router and, just in case these tweaks screw everything up, have to ability to get everything back to the same state it was when the tmpfs overlay got mounted by power cycling the router.
The device is a netgear R9000 running firmware built from egorenar's openwrt fork. Heres the relevant output from mount
:
/dev/ubiblock0_0 on /rom type squashfs (ro,relatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,compr=zlib,assert=read-only,ubi=0,vol=1)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
I tried the running the following:
mkdir -p /tmp/overlay_tmpfs/upper /tmp/overlay_tmpfs/work
mount -t overlay -o rw,noatime,\
lowerdir=/overlay/upper:/,\
upperdir=/tmp/overlay_tmpfs/upper,\
workdir=/tmp/overlay_tmpfs/work \
overlayfs:/overlay_tmpfs /
These commands run but,unfortunately, dont do anything. Everything written to /
gets saved in /overlay/upper
...../tmp/overlay_tmpfs/{upper,work}
have nothing in them.
Any idea what the problem is?
NOTE1: If I manually set up a layered overlay (e.g., using the commands below) then things work like they are supposed to. It is just when trying to mount the overlay to /
that it doesnt work.
mkdir -p tmp/overlay_tmpfs
cd /tmp/overlay_tmpfs
mkdir -p lower upper work upper1 work1
mount -t overlay -o rw,noatime,\
lowerdir=/tmp/overlay_tmpfs/lower,\
upperdir=/tmp/overlay_tmpfs/upper,\
workdir=/tmp/overlay_tmpfs/work \
overlayfs:/overlay_tmpfs0 /tmp/overlay/lower
echo 'test' > /tmp/overlay_tmpfs/lower/test0
find /tmp/overlay_tmpfs -name 'test0' # shows up at /tmp/overlay_tmpfs/lower/test0 and at /tmp/overlay_tmpfs/upper/test0
mount -t overlay -o rw,noatime,\
lowerdir=/tmp/overlay_tmpfs/upper:/tmp/overlay_tmpfs/lower,\
upperdir=/tmp/overlay_tmpfs/upper1,\
workdir=/tmp/overlay_tmpfs/work1 \
overlayfs:/overlay_tmpfs1 /tmp/overlay/lower
echo 'test' > /tmp/overlay_tmpfs/lower/test1
find /tmp/overlay_tmpfs -name 'test1' # shows up at /tmp/overlay_tmpfs/lower/test1and at /tmp/overlay_tmpfs/upper1/test1. Is not present at /tmp/overlay_tmpfs/upper/test
NOTE2: This behavior has been documented a few other times via questions on the openwrt forum (here and here). Unfortunately these questions never got a solution....The closest thing to a solution is a suggestion that fiddling with "something" in the preinit source files and then recompiling might work.