Mounting immutable file-system with AUFS or OverlayFS

I needed a way of mounting a md-raid set readonly but needed the ability to change permissions without affecting the original disks

Methods

Issues

copy_up operation
overlay2 needs kernel 4+

AUFS

https://www.thegeekstuff.com/2013/05/linux-aufs/
https://packages.debian.org/search?keywords=fsprotect

OverlayFS

https://docs.docker.com/storage/storagedriver/overlayfs-driver/
https://blog.programster.org/overlayfs

Procedure

Prepping the Images

Install the required package
# apt-get install aufs-tools
# apt-get install fuse-overlayfs

Make the directories for the test
# mkdir /mnt/diskro
# mkdir /mnt/diskram
# mkdir /mnt/diskcombi

Create an image file for use as a read-only source
# dd if=/dev/zero of=/root/disk.img bs=512 count=2024000
# mkfs.ext4 /root/disk.img

Mount RO image and copy some files to the drive and remount as RO
# mount /root/disk.img /mnt/diskro
# cp – R something /mnt/diskro
# mount -o remount,ro /root/disk.img /mnt/diskro

Create a temp file system on ram
# mount -t tmpfs -o size=1G none /mnt/diskram

Mounting the images using different methods.

Using AUFS to mount the RO file system with the RAM drive for writes.
# mount -t aufs -o br:/mnt/diskram/:/mnt/diskro/=ro none /mnt/diskcombi/

Using OverlayFS to mount as above
# mount -t overlay -o lowerdir=/mnt/diskro,upperdir=/mnt/diskram/upperdir,workdir=/mnt/diskram/workdir none /mnt/diskcombi