1

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

thanks

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/
root@ip-10-0-0-48:/tmp#
  • 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 '16 at 7:40
  • @techraf You can certainly mount an overlayfs filesystem to /. It's a pretty common scenario. – Gilles 'SO- stop being evil' Dec 13 '16 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. – Gilles 'SO- stop being evil' Dec 13 '16 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 '16 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. – Gilles 'SO- stop being evil' Dec 13 '16 at 23:24
0

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.

#/bin/bash
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[@]}"
do
  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}
done
|improve this answer|||||

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.