(no commit message)
authorstephan48 <stephan48@web>
Sat, 25 Mar 2023 15:11:07 +0000 (16:11 +0100)
committerIkiWiki <ikiwiki.info>
Sat, 25 Mar 2023 15:11:07 +0000 (16:11 +0100)
posts/2023-03-25-resize-partition-backed-encrypted-mdadm-lvm-pv.mdwn [new file with mode: 0644]

diff --git a/posts/2023-03-25-resize-partition-backed-encrypted-mdadm-lvm-pv.mdwn b/posts/2023-03-25-resize-partition-backed-encrypted-mdadm-lvm-pv.mdwn
new file mode 100644 (file)
index 0000000..9c27037
--- /dev/null
@@ -0,0 +1,97 @@
+I have a couple of systems which have a variation of the following "stack":
+- Physical Disks(does not matter the type)
+- Partitions
+- mdadm raid*
+- dm-crypt luks
+- lvm or partition
+
+We need some infos:
+
+- Identify the relevant vg to extend
+- Identify which cryptsetup volume/source underpins the pv
+- Identify which raid underpins the dm-crypt volume
+- Identity physical disks
+
+Alls of this can be found via a simple call to lsblk:
+
+```
+$ lsblk
+...
+nvme0n1                                                    259:0    0   1.7T  0 disk
+├─nvme0n1p1                                                259:1    0   953M  0 part
+└─nvme0n1p2                                                259:2    0 837.3G  0 part
+  └─md127                                                    9:127  0 837.1G  0 raid1
+    └─frey-fast-crypt                                      253:88   0   744G  0 crypt
+      ├─frey--fast--vg-v1_temp                             253:1    0    35G  0 lvm
+...
+nvme1n1                                                    259:4    0   1.7T  0 disk
+├─nvme1n1p1                                                259:5    0   953M  0 part
+└─nvme1n1p2                                                259:6    0 837.3G  0 part
+  └─md127                                                    9:127  0 837.1G  0 raid1
+    └─frey-fast-crypt                                      253:88   0   744G  0 crypt
+      ├─frey--fast--vg-v1_temp                             253:1    0    35G  0 lvm
+...
+```
+
+This will nicely show *all* the relevant informations, like the VG, the raid, the physical disks, the partitions.
+
+
+To resize this we need to do the following steps in order:
+
+```
+$ cat /proc/mdadm
+md1 : active raid1 ***sda2***[1] ***sdb2***[0]
+      3669883904 blocks super 1.2 [2/2] [UU]
+      bitmap: 12/28 pages [48KB], 65536KB chunk
+```
+- Check if we have capacity to resize the underlying partitions(the infos marked with *** are the relevant ones) (do this on all raid disks)
+
+```
+$ parted /dev/nvme1n1
+GNU Parted 3.4
+Using /dev/nvme1n1
+Welcome to GNU Parted! Type 'help' to view a list of commands.
+(parted) print
+Model: SAMSUNG MZQLB1T9HAJR-00007 (nvme)
+Disk /dev/nvme1n1: ***1920GB***
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number  Start   End     Size   Type     File system  Flags
+ 1      1049kB  1000MB  999MB  primary
+ 2      1000MB  ***900GB***   899GB  primary
+
+(parted)
+```
+- Resize the Partitions (do this on all raid disks)
+
+```
+$ parted /dev/nvme1n1
+GNU Parted 3.4
+(parted) resizepart 2 1000G
+- Reisze the RAID
+```
+$ mdadm --grow  --size=max /dev/md127
+```
+- Resize cryptsetup volume
+
+```
+$ cryptsetup resize frey-fast-crypt
+Enter passphrase for /dev/md127:
+```
+- Resize the PV volume
+
+```
+pvresize /dev/mapper/frey-fast-crypt
+  Physical volume "/dev/mapper/frey-fast-crypt" changed
+  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
+```
+- Check that it worked
+
+```
+$ pvs
+  PV                                                    VG           Fmt  Attr PSize   PFree
+  /dev/mapper/frey-fast-crypt                           frey-fast-vg lvm2 a--  837.11g 159.11g
+...
+```