You are not logged in.

#1 2016-05-05 15:58:40

marble
Member
Registered: 2016-02-05
Posts: 9

[Solved] Manipluating fstab and tmpfiles.d order

Hello,
in order to mount a system read-only and still make it appear writable during run time, I wanted to user overlayfs.
All the changes made to the overlay shall be volatile, therefore my plan was to place the upper and work (and also the merge) directory in a tmpfs (/tmp).
I already managed to make tmpfiles.d create the folders at boot.
Upper and work dir must be in under the same mount point and must not be the same directory.

Now the problem seems to be that tmpfiles.d stuff is executed after fstab stuff is executed and therefore the overlay line in the fstab fails.

line from the /etc/fstab:

 overlay		/tmp/merge	overlay noauto,x-systemd.automount,lowerdir=/home/alarm,upperdir=/tmp/upper,workdir=/tmp/work 	0 	0 

/etc/tmpfiles.d/overlay.conf:

D /tmp/upper	0777 root root
D /tmp/work	0777 root root
D /tmp/merge	0777 root root 

Is there a way to make the line in the fstab to be executed at a certain runlevel?
I could write an unit file for the overlay mount, but I wanted to do it the elegant way.

Last edited by marble (2016-05-05 21:18:13)

Offline

#2 2016-05-05 16:41:31

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Manipluating fstab and tmpfiles.d order

I don't understand how overlaying a home directory would allow the system to run read-only.

But in any case, I'd suggest checking out liveroot, maybe it provides the functionality you're looking for.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#3 2016-05-05 19:27:16

marble
Member
Registered: 2016-02-05
Posts: 9

Re: [Solved] Manipluating fstab and tmpfiles.d order

The goal is to mount the file system as read-only but make it appear to programs as writable.

Offline

#4 2016-05-05 20:12:51

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Manipluating fstab and tmpfiles.d order

I still don't understand exactly what you're trying to do. In your original post you said "mount a system read-only" and I assumed you wanted to boot an entire system this way, which is why I recommended liveroot. But if you just want to do this with one filesystem that's a different matter.

Now the problem seems to be that tmpfiles.d stuff is executed after fstab stuff is executed and therefore the overlay line in the fstab fails.

Have you verified this is the case by looking at journal, or is this just what you think is happening?

Before making the fstab and tmpfiles entries, did you confirm that manually doing the same things works?


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2016-05-05 21:11:25

marble
Member
Registered: 2016-02-05
Posts: 9

Re: [Solved] Manipluating fstab and tmpfiles.d order

Okay, I found a simple solution.
Instead of using fstab one can create a systemd .mount unit

/etc/systemd/system/tmp-merge.mount

[Unit]
Description = mounts merged overlay
After = systemd-tmpfiles-setup.service
Conflicts = umount.target

[Mount]
What = overlay
Where = /tmp/merge
Type = overlay
Options = lowerdir=/home/alarm/,upperdir=/tmp/upper/,workdir=/tmp/work/

[Install]
WantedBy = multi-user.target

Enable the unit and Bob's your uncle.

Last edited by marble (2016-05-05 23:25:19)

Offline

Board footer

Powered by FluxBB