linuxfilesystemsopenwrtoverlayfs

Overlayfs: restore removed or changed file from "lower"


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

Solution

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

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