The commands below should be creating a root overlay, such that any modifications to root will appear in /tmp/upper

However as you can see it does not appear to be working. Can anyone suggest what I am doing wrong?

I am following the syntax here: https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt


ubuntu@ip-10-0-0-48:~$ sudo su
root@ip-10-0-0-48:/home/ubuntu# cd /tmp
root@ip-10-0-0-48:/tmp# mkdir upper
root@ip-10-0-0-48:/tmp# mkdir workdir
root@ip-10-0-0-48:/tmp# mount -t overlay overlay -olowerdir=/,upperdir=/tmp/upper,workdir=/tmp/workdir  /
root@ip-10-0-0-48:/tmp# touch /floob
root@ip-10-0-0-48:/tmp# ls /
bin  boot  dev  etc  floob  home  initrd.img  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var  vmlinuz  x
root@ip-10-0-0-48:/tmp# ls /tmp/upper/
  • You are asking the same question as this one. Where did you get the idea that mounting to / will succeed? Certainly not from the referenced document. You can mount elsewhere and chroot.
    – techraf
    Dec 13, 2016 at 7:40
  • @techraf You can certainly mount an overlayfs filesystem to /. It's a pretty common scenario. Dec 13, 2016 at 22:59
  • But I'm not sure if you can do it directly. You may have to mount it on a subdirectory and chroot into it. At least that's what overlayroot does. Dec 13, 2016 at 23:06
  • @Gilles Ok, so what happens to current processes, open files? They suddenly switch to the overlay-mounted root? Regarding your second comment, you are repeating my words ("month elsewhere"). I am confused now.
    – techraf
    Dec 13, 2016 at 23:16
  • @techraf Open files keep using the lower filesystem, no matter how you do it. That's why an overlay root is usually established from by the initramfs. Dec 13, 2016 at 23:24

1 Answer 1


In the end I just created a bunch of overlays, one for each of the top level directories that I was interested in.

The point of the exercise was to isolate changes made during package installation and this seems to do it well enough for the most part.

array=( lib home opt bin boot var etc usr srv lib64 root sbin  )
mkdir -p /ovl
cd /ovl
rm -rf /ovl/overlay
rm -rf /ovl/workdir
mkdir -p /ovl/overlay
mkdir -p /ovl/workdir

for i in "${array[@]}"
  mkdir -p /ovl/overlay/${i}
  mkdir -p /ovl/workdir/${i}
  mount -t overlay overlay -o lowerdir=/${i},upperdir=/ovl/overlay/${i},workdir=/ovl/workdir/${i} /${i}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.