LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Overlay Mounts (https://www.linuxquestions.org/questions/linux-general-1/overlay-mounts-4175640587/)

Quantumstate 10-17-2018 01:36 PM

Overlay Mounts
 
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?

bradvan 10-18-2018 05:00 AM

You might want to just to /var/log instead of all of /var. More goes in /var than just logs. Did you look at: OverlayFS? This link also seems applicable: MOUNTING A FILE SYSTEM.

Quantumstate 10-22-2018 10:37 AM

Can't just do logs because of spool, cache, tmp, and other unanticipated subdirs which may need write depending on the application.

I hadn't seen that RHEL article, thanks. There's a bad gotcha with XFS, which is the default filesystem on install. I doubt it's being created with that switch.

Shared mounts aren't really applicable. Overlay is a different animal. And Arch's article hasn't helped at all.

What I know so far is that in order to do the overlay mount early enough in init so as not to modify the underlying /var, it must be done by a script in /usr/local/lib/dracut/modules.d something like this:
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

... but I'm still working on it as I get time. This script would be picked up by dracut and put in initramfs to be executed right after mount of the / filesystem.

Quantumstate 11-03-2018 12:29 AM

Great. Nobody knows dracut in-depth.

bradvan 11-05-2018 04:38 AM

Sorry, this is the first I've heard of overlayfs. I did a google search on:
Code:

rhel 7 overlay mounts site:redhat.com
and it came up with some interesting hits. The RHEL 7.3 release notes had some good information. There is a pdf presentation about security of overlayfs. I did not see anywhere that you had to write dracut modifications to get it to work. Maybe you are working on some older information?


All times are GMT -5. The time now is 04:19 AM.