0

I have added a second disk to my LVM system. I created a physical volume there, added it to the volume group of ubuntu, 'vgubuntu', extended logical volume to fill the whole disk. How do I extend the LUKS system partition to fill the whole logical volume? Here's more info provided by pvdisplay, vgdisplay and lvdisplay:

  --- Physical volume ---
  PV Name               /dev/mapper/nvme0n1p3_crypt
  VG Name               vgubuntu
  PV Size               <464.53 GiB / not usable 0   
  Allocatable           NO
  PE Size               4.00 MiB
  Total PE              118919
  Free PE               0
  Allocated PE          118919
  PV UUID               DwO3R1-DeRo-c83D-qx5F-xjC5-icXG-x3j28i
 
  --- Physical volume ---
  PV Name               /dev/nvme1n1p1
  VG Name               vgubuntu
  PV Size               <476.94 GiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              122096
  Free PE               0
  Allocated PE          122096
  PV UUID               9UyJR4-m0G9-sYPG-BBkW-2WEg-TBdR-DAj0u3



root@omen15:~# vgdisplay
  --- Volume group ---
  VG Name               vgubuntu
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               941.46 GiB
  PE Size               4.00 MiB
  Total PE              241015
  Alloc PE / Size       241015 / 941.46 GiB
  Free  PE / Size       0 / 0   
  VG UUID               ANNTFf-p9hU-O4R3-jwDQ-bZhP-v8tm-hVL8Fn


root@omen15:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgubuntu/root
  LV Name                root
  VG Name                vgubuntu
  LV UUID                rxnIOU-yNg2-ythJ-Dz5V-N3Sr-X7DQ-WzbUUF
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2021-07-24 17:25:39 +0300
  LV Status              available
  # open                 1
  LV Size                <940.51 GiB
  Current LE             240770
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
 
  --- Logical volume ---
  LV Path                /dev/vgubuntu/swap_1
  LV Name                swap_1
  VG Name                vgubuntu
  LV UUID                MOvhEP-64w3-wHHO-wmDh-YkSU-XARL-7hRQIf
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2021-07-24 17:25:39 +0300
  LV Status              available
  # open                 2
  LV Size                980.00 MiB
  Current LE             245
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

And here's what df -h prints:

root@omen15:~# df -h
Filesystem                 Size  Used Avail Use% Mounted on
tmpfs                      1.6G  2.1M  1.6G   1% /run
/dev/mapper/vgubuntu-root  925G  7.3G  871G   1% /
tmpfs                      7.6G   12M  7.6G   1% /dev/shm
tmpfs                      5.0M  4.0K  5.0M   1% /run/lock
tmpfs                      4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/nvme0n1p2             705M  251M  403M  39% /boot
/dev/nvme0n1p1             511M  5.3M  506M   2% /boot/efi
tmpfs                      1.6G  2.0M  1.6G   1% /run/user/1000
0

You have LUKS configured on the PV level so "under" your LVM setup so unfortunately you need to start over -- your PV must be encrypted you can't "extend" the existing LUKS/dm-crypt device to the second disk. The structure should look like disk -> partition -> LUKS -> PV -> VG -> LV (it is possible to configure encryption on the LV level but your existing configuration is encrypted on the PV level).

So you need to shrink your root LV back, remove your newly created PV from vgubuntu and then create LUKS on nvme1n1p1 (cryptsetup luksFormat /dev/nvme1n1p1), unlock it (cryptsetup luksOpen /dev/nvme1n1p1 nvme1n1p1_crypt) and use /dev/mapper/nvme1n1p1_crypt as the second PV. You'll also need to add the new LUKS device to /etc/crypttab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.