Can overlayfs follow mounts in lowerdir?
Hi,
I'm trying to use overlay to create temporary virtual root filesystem. I need a copy of / with custom files on top of it.
To achieve that I used a simple mount like this:
mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/ov/upper,workdir=/tmp/ov/work /tmp/ov/virtual
In /tmp/ov/virtual/ I can see my main filesystem and I can make temporary changes to it. Almost perfect!
The problem are mounts. I have some standard ones:
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)
They are not visible in my virtual root:
# ls -l /tmp/ov/proc/ # ls -l /tmp/ov/sys/ # ls -l /tmp/ov/tmp/ (all empty)
Would that be possible to make overlayfs follow such mounts in lowerdir?
Signature · 1 line
Rafał
Christian Brauner
maintainerQuoted 16 lines · Rafał Miłecki
Hi,
I'm trying to use overlay to create temporary virtual root filesystem. I need a copy of / with custom files on top of it.
To achieve that I used a simple mount like this:
mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/ov/upper,workdir=/tmp/ov/work/tmp/ov/virtualIn
/tmp/ov/virtual/I can see my main filesystem and I can make temporary changes to it. Almost perfect!The problem are mounts. I have some standard ones:
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)
Quoted 7 lines
They are not visible in my virtual root:
# ls -l /tmp/ov/proc/ # ls -l /tmp/ov/sys/ # ls -l /tmp/ov/tmp/ (all empty)Would that be possible to make overlayfs follow such mounts in lowerdir?
No, this doesn't work:
* overlayfs does clone mounts recursively
* procfs can't be used as a lower layer
So they would need to be bind-mounted on top of these locations.
Quoted 23 lines · Christian Brauner
Quoted 22 lines · Rafał Miłecki
Hi,
I'm trying to use overlay to create temporary virtual root filesystem. I need a copy of / with custom files on top of it.
To achieve that I used a simple mount like this:
mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/ov/upper,workdir=/tmp/ov/work/tmp/ov/virtualIn
/tmp/ov/virtual/I can see my main filesystem and I can make temporary changes to it. Almost perfect!The problem are mounts. I have some standard ones:
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)They are not visible in my virtual root:
# ls -l /tmp/ov/proc/ # ls -l /tmp/ov/sys/ # ls -l /tmp/ov/tmp/ (all empty)
Quoted 8 lines
Quoted 1 line
Would that be possible to make overlayfs follow such mounts in lowerdir?
No, this doesn't work:
* overlayfs does clone mounts recursively
* procfs can't be used as a lower layerSo they would need to be bind-mounted on top of these locations.
Can I bind mount /tmp/ to my temporary virtual root and still make use or overlay to don't touch underlaying system?
If I do:
mount -o bind /tmp /tmp/ov/virtual/tmp
then writing anything to /tmp/ov/virtual/tmp/ would affect original tmp.
Quoted 2 lines · Rafał Miłecki
Can I bind mount
/tmp/to my temporary virtual root and still make use or overlay to don't touch underlaying system?
You can bind mount read-only, or you can create a separate overlay. For /proc and /sys the only option is a r/o bind.
Thanks,
Miklos