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

I want to resize them online, without shutting down the system or components at all. This is the documentation how i normally do this.

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:

  • Check initial status:
# pvs
  PV                                                    VG           Fmt  Attr PSize   PFree
  /dev/mapper/frey-fast-crypt                           frey-fast-vg lvm2 a--  743.98g 65.98g
  • 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
  • Resize 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
...

If you don't have a LVM on/inside the LUKS/cryptsetup you can just use your filesystems resize mechanism:

resize2fs /dev/mapper/frey-fast-crypt