I have looked at How do I use OverlayFS? but it doesn't answer my question.
I need to install some third party applications and they require /opt
to be writable but the device I am running on has /opt
on a readable rootfs. Essentially, I have a directory /opt
on a read-only filesystem (lower) and let's say I have a read-write directory /mnt/optw
(writable). I would like to merge /opt
& /mnt/optw
and mount it to /opt
.
Is this possible at all?
You could bind
/mnt/optw
to/opt
like so:This way
/opt
will be a reflection of/mnt/optw
contents and permissions.To access the contents of the two directories under
/opt
, mount withaufs
like so:This way, the two directories are merged and you'll be able to access their contents under
/opt/
.Notice:
If you do not have
aufs
support available on your system, you can add support by installingaufs-tools
like so:For further reading man aufs.
This can also be achieved through kernel in-built
overlayfs
module:That can be checked to be properly mounted as: