I can't seem to master overlay mounts. (CentOS 7.5)
I want to move changes to /var into tmpfs. Before anyone panics I'll be shipping logs to a log server.
I've created a script called /usr/local/lib/dracut/modules.d/var-mount.sh
Code:
if ! ismounted /run/var; then
mkdir -m 0755 /run/var
mount -t tmpfs -o rw,nosuid,nodev,noexec,strictatime,size=512m,mode=0775 tmpfs /run/var >/dev/null
mkdir -m 0777 /run/var/upper
mkdir /run/var/work
mount -t overlay -o lowerdir=/var,upperdir=/run/var/upper,workdir=/run/var/work /run/var >/dev/null
fi
This will be integrated into initramfs next time I run dracut, to be executed on each boot.
Executing these lines singlely, everything works except the overlay mount.
Code:
# mount -t overlay -o lowerdir=/var,upperdir=/run/var/upper,workdir=/run/var/work /run/var
mount: wrong fs type, bad option, bad superblock on tmpfs,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
# dmesg
...
[ 3463.917113] overlayfs: unrecognized mount option "size=524288k" or missing value
Huh? Why doesn't it object to this on the /run/var mount?
Has anyone else successfully moved /var to tmpfs using overlay?