Overlayfs: restore removed or changed file from "lower"

5.3k Views Asked by At

OpenWrt uses overlayfs

# mount | grep overlay
/dev/ubi0_2 on /overlay type ubifs (rw,noatime)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)

Somehow real lowerdir is /rom

# mount | grep rom
mtd:ubi_rootfs on /rom type squashfs (ro,relatime)

How to restore file to make it the as in /rom? Remove records from overlays: whiteouts and opaque dirs.

Workaround

cp /rom/path/to/file /overlay/upper/path/to/file
1

There are 1 best solutions below

2
On BEST ANSWER

Remove file from /overlay/upper, and then remount rootfs.

rm /overlay/upper/my/file
mount -o remount /