Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Encrypted hard drives on LVM and urgent power shutdowns.
Date: Mon, 12 Sep 2022 05:58:54
Message-Id: 5df10fd6-545e-9272-b401-79456246687d@gmail.com
In Reply to: Re: [gentoo-user] Encrypted hard drives on LVM and urgent power shutdowns. by tastytea
1 tastytea wrote:
2 > On 2022-09-11 20:56-0500 Dale <rdalek1967@×××××.com> wrote:
3 >
4 >> Howdy,
5 >>
6 >> Last night we had some bad weather where I live and we ended up with
7 >> some power problems.  Ironically they went out a few hours after the
8 >> storm was gone.  Anyway.  I had all sorts of encrypted drives open.
9 >> My usual drives inside my puter plus the large 14TB external backup
10 >> drive that is still copying files over.  Glad my UPS held up while I
11 >> closed all those drives and did a proper shutdown.  Doing all that
12 >> tho, it made me think about if I wasn't here to do all that.  Being
13 >> Linux, I'd suspect that upsmon would tell the puter to do a proper
14 >> shutdown which includes unmounting the file system, closing the
15 >> encrypted drives, like I do with cryptsetup close <name> etc and then
16 >> shutting down.  However, one has to ask, is it set up to do so by
17 >> default?  I manage the encrypted drives manually.  I don't use the
18 >> crypt services for that like people do when all of the system
19 >> drive(s) is encrypted or when just /home is encrypted.  My encrypted
20 >> stuff is mounted within /home or for the external backups, in /mnt.
21 >> Thing is, some aren't open unless I'm using them or are external.
22 >> Since I do it manually, is there a tool that sees they need
23 >> unmounting and closing and does it or do I need to do something to
24 >> make sure it is done before a shutdown? 
25 >>
26 >> I suspect this would happen on its own but I'd like to make sure.  I'd
27 >> hate to mess up the file system badly on any of my drives or in a
28 >> worst case scenario, brick a hard drive with some 1 in a million
29 >> chance problem.
30 >>
31 >> I thought about having a drive connected, open and mounted that I
32 >> don't really need and just do a shutdown, see what happens.  Then
33 >> again, why not ask and see if anyone else has had this happen and if
34 >> things turned out OK or if there was problems.  I'm lucky, most of
35 >> the time I'm either home or very close by.  Still, it can happen when
36 >> I'm not here.  I already wonder if upsmon will kick in correctly and
37 >> do a proper shutdown.  After all, it has never had to before.  I'm
38 >> running on faith that it will.  I hope I'm right. 
39 >>
40 >> Thoughts?  Default will take care of things?  I need to take steps to
41 >> be sure in case I'm not here?  Personal experience?  A good theory?
42 >> ;-)
43 > Yes, /etc/init.d/mount-ro will take care of that. It first calls `sync`
44 > and then calls `umount -r` on everything. It's set up to ruin on
45 > shutdown by default. I'm sure systemd does something similar.
46 >
47 > I don't think `cryptsetup luksClose` is necessary on shutdown, since it
48 > only sets up the mapping(?).
49 >
50 > Kind regards, tastytea
51 >
52 >
53
54
55 Thanks much for this info.  I figured there was some tool that would do
56 that regardless of what it was.  I know regular file systems would be
57 and couldn't imagine that encrypted would be any different but I didn't
58 want to find out I was wrong the hard way.  After all, this 14TB backup
59 has been running for a few days now. Even when it gets through, I have
60 to run it again because of additions and other changes I made in the
61 past few days.  While I could just start over with a fresh backup if it
62 got damaged, it would be time consuming to do so.  Also, it would put
63 data at risk if I had a failure of the running drives while that backup
64 was not available.  Not likely but bad things happen. 
65
66 Next time power fails, I'll just stop all the processes I can and then
67 do a shutdown, knowing that everything will close safely.  That will
68 save me some battery time as well. 
69
70 Thanks much. 
71
72 Dale
73
74 :-)  :-)