Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Replace 8TB drive with 10TB drive on encrypted LVM
Date: Wed, 14 Sep 2022 05:40:29
Message-Id: 1ccd5f4b-d5e9-e8f3-10f1-8c4abcba8f55@gmail.com
In Reply to: [gentoo-user] Replace 8TB drive with 10TB drive on encrypted LVM by Dale
1 Dale wrote:
2 > Howdy,
3 >
4 > I thought I had done this before but it appears I have not.  I want to
5 > replace a 8TB drive with a 10TB drive and then remove the 8TB drive when
6 > done but these drives are encrypted with cryptsetup on top of LVM.  I
7 > looked through my how tos and can't find one for encrypted drives.  I
8 > did find them for regular LVM and have done that in the past.  While I
9 > have fresh backups, I don't want to test them if not needed.  Does this
10 > work just like with LVM or does the encryption change how this is done
11 > or even if it can be done?
12 >
13 > I googled and can't really find a good how to.  Does anyone have a link
14 > to a 'how to' to do this with encrypted stuff, have notes with the
15 > sequence of commands that I can go by or is this not doable when it is
16 > encrypted? 
17 >
18 > Thanks.
19 >
20 > Dale
21 >
22 > :-)  :-) 
23 >
24
25
26 Since my previous post, I've continued to look for a way to do this on
27 google, youtube and any place else I can think of.  So far, I have yet
28 to find a way.  Given no one has replied with info, I'm assuming that no
29 one here knows or can find a way either.  Since this involves LVM which
30 I know has this ability, it appears that the encryption part complicates
31 matters but it should be doable, I have two drives in the current setup
32 so I at least added a drive once before.  So, I updated my backups,
33 stopped any changes to the affected LVM and set out to test my theory. 
34 This is a list of commands in sequence that are from my notes, you may
35 recall my memory isn't great.  lol 
36
37 To replace drive on encrypted LVM. 
38 pvcreate /dev/sd<*new* drive or partition>
39 vgextend <group name> /dev/sd<*new* pvdevice above>
40 pvmove /dev/sd<drive being *removed*>  This takes a while. ;-)
41
42 vgreduce crypt /dev/sd<drive being *removed*>
43 pvremove /dev/sd<drive being *removed*>
44
45 To add extra/remaining space on replacement drive if any
46 vgdisplay <name of vg> and get unused space or PE available if using
47 --extents option or use 100% option
48 lvresize -l +100%FREE /dev/<pv name>/vg name> EXAMPLE
49 lvresize -l +100%FREE /dev/crypt/crypt
50
51 If LUKS, resize LUKS with
52 cryptsetup resize <name of encrypted>
53 or close and reopen.
54
55 resize2fs -p /dev/mapper/<name of lv which should be same as mount
56 point>  EXAMPLE
57 resize2fs -p /dev/mapper/crypt
58
59 Once this was done, I have a previous 8TB and a larger 10TB drive which
60 gives me 17TBs of space now.  I plan to buy a 12 or 14TB drive to
61 replace existing 8TB.  I should be done for a while. 
62
63 Now to replace my /home drive which is also close to full.  It's not
64 encrypted tho. The biggest difference in this and plain LVM, resizing
65 with cryptsetup or close and reopen.  Keep in mind, while I did all
66 this, LUKS, cryptsetup, whatever was open.  I'm not sure about this
67 being done while closed.  I did find one mention that it had to be open
68 at certain points. 
69
70 By the way, if someone wants to take this and make a how to out of it
71 somewhere, I think it would be great.  This is doable.  I even rebooted
72 and even tho the drives changed SATA ports, it worked fine.  So, I guess
73 I did it right, even if no one thought it could be done.  lol 
74
75 I really hope this helps someone else.  My brain hurts a little.  :/
76
77 Dale
78
79 :-)  :-) 

Replies