Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Encrypted hard drives on LVM and urgent power shutdowns.
Date: Mon, 12 Sep 2022 17:28:09
Message-Id: CAGfcS_mYFYpcg4+So648q5Sckes39pWjJFyoK+pMjmZVLcxG6g@mail.gmail.com
In Reply to: [gentoo-user] Encrypted hard drives on LVM and urgent power shutdowns. by Dale
1 On Sun, Sep 11, 2022 at 9:56 PM Dale <rdalek1967@×××××.com> wrote:
2 >
3 > I suspect this would happen on its own but I'd like to make sure. I'd
4 > hate to mess up the file system badly on any of my drives or in a worst
5 > case scenario, brick a hard drive with some 1 in a million chance problem.
6 >
7
8 I just wanted to comment that LUKS encryption on linux is pretty-much
9 a block-level passthrough. So if your filesystem is journaled and
10 using barriers or syncing to ensure consistency, and you add LUKS to
11 it, then you shouldn't really see any difference in behavior if it is
12 interrupted uncleanly by a power loss. The encryption could add a bit
13 of latency but that shouldn't change much.
14
15 Of course different filesystems handle interruptions differently, and
16 all those caveats still apply.
17
18 As far as unmounting goes, you just need to umount the filesystem.
19 umount will block until all writes are synced to disk, and that
20 includes all layers like LVM/LUKS/mdadm/whatever that might be
21 underneath it. If umount returns, then all your data is written to
22 disk and if at that instant you lose power there will be no data loss
23 for that filesystem. I guess if you're using mdadm and you have
24 multiple filesystems not aligned to a stripe boundary, then the raid
25 write hole might still apply, and that is true at anytime whether the
26 filesystem is mounted or not - data on a stripe shared with some other
27 active filesystem could get lost in some situations.
28
29 Obviously if you lose the key to a LUKS filesystem or if there is some
30 kind of bug in LUKS the use of encryption could hinder data recovery.
31 Beyond that it really shouldn't have any impact on anything. I guess
32 it would also give you more exposure to RAM errors (since that is
33 another code path that stores stuff in RAM).
34
35 As already discussed, clean shutdowns triggered by NUT/etc are of
36 course best, but the use of LUKS shouldn't change much with the use of
37 a UPS otherwise.
38
39 --
40 Rich