Gentoo Archives: gentoo-dev

From: Richard Yao <ryao@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] rfc: Does OpenRC really need mount-ro
Date: Wed, 17 Feb 2016 14:06:02
Message-Id: 996CC8AD-B0D7-4161-B8DF-1E0CFD983C7E@gentoo.org
In Reply to: Re: [gentoo-dev] rfc: Does OpenRC really need mount-ro by William Hubbs
1 > On Feb 16, 2016, at 1:41 PM, William Hubbs <williamh@g.o> wrote:
2 >
3 >> On Tue, Feb 16, 2016 at 01:22:13PM -0500, Rich Freeman wrote:
4 >>> On Tue, Feb 16, 2016 at 1:05 PM, William Hubbs <williamh@g.o> wrote:
5 >>>
6 >>> The reason it exists is very vague to me; I think it has something to do
7 >>> with claims of data loss in the past.
8 >>
9 >> Is there some other event that will cause all filesystems to be
10 >> remounted read-only or unmounted before shutdown?
11 >
12 > When localmount/netmount stop they try to unmount file systems they know
13 > about, but they do not try to remount anything.
14 >
15 >
16 >> You definitely will want to either unmount or remount readonly all
17 >> filesystems prior to rebooting. I don't think the kernel guarantees
18 >> that this will happen (I'd have to look at it). Just doing a sync
19 >> before poweroff doesn't seem ideal - if nothing else it will leave
20 >> filesystems marked as dirty and likely force fscks on the next boot
21 >> (or at least it should - if it doesn't that is another opportunity for
22 >> data loss).
23 >>
24 >> There are different ways of accomplishing this of course, but you
25 >> really want to have everything read-only in the end.
26 >
27 > unmounting is easy enough; we already do that.
28 >
29 > What I'm trying to figure out is, what to do about re-mounting file
30 > systems read-only.
31 >
32 > How does systemd do this? I didn't find an equivalent of the mount-ro
33 > service there.
34
35 One idea proposed by systemd that is almost never used in production is to fall back to an initramfs environment to undo the boot process by umounting /. It would not surprise me if the normal case were hard coded to remount / as ro because you risk filesystem corruption otherwise. Journaling filesystems are fairly good at surviving that, but you are still taking a risk due to partial writes and anyone using ext2 would be taking a much bigger gamble.
36 >
37 > William