Description of problem: LV + LUKs, where the LV is active, but the LUKS is not. Using --fs resize will cause lvextend's fs check to fail and the error code will be non zero, however, the resize of the volume will still happen. SCENARIO - luks_no_fs_inactive_resizefs_extend: Create a variety of Encrypted LUKS LV types and attempt to extend the size while INACTIVE and w/o a filesystem, but with the use of --fs resize adding entry to the devices file for /dev/sda creating PV on virt-557.cluster-qe.lab.eng.brq.redhat.com using device /dev/sda creating VG on virt-557.cluster-qe.lab.eng.brq.redhat.com using PV(s) /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde vgcreate resize_matrix /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde Volume group "resize_matrix" successfully created lvcreate --yes --type linear -n resize_lv -L 30G resize_matrix Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Logical volume "resize_lv" created. 'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv' 'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks' 'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks' deactivating LV resize_lv on virt-557.cluster-qe.lab.eng.brq.redhat.com lvchange --yes -an resize_matrix/resize_lv Adding additional space to resize_matrix/resize_lv on virt-557.cluster-qe.lab.eng.brq.redhat.com lvextend --yes --fs resize -L +446M resize_matrix/resize_lv [root@virt-557 ~]# lvs -a -o +devices LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices resize_lv resize_matrix -wi------- 30.00g /dev/sda(0) [root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv Rounding size to boundary between physical extents: 448.00 MiB. Logical volume resize_matrix/resize_lv must be active for file system resize. [root@virt-557 ~]# lvchange -ay resize_matrix [root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv Rounding size to boundary between physical extents: 448.00 MiB. Size of logical volume resize_matrix/resize_lv changed from 30.00 GiB (7680 extents) to <30.44 GiB (7792 extents). Cannot find active LUKS dm-crypt device using resize_matrix/resize_lv. File system extend error. Logical volume resize_matrix/resize_lv successfully resized. [root@virt-557 ~]# echo $? 5 [root@virt-557 ~]# echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks [root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv Rounding size to boundary between physical extents: 448.00 MiB. Size of logical volume resize_matrix/resize_lv changed from <30.44 GiB (7792 extents) to <30.88 GiB (7904 extents). File system found on crypt device /dev/dm-3 on LV resize_matrix/resize_lv. No file system found on /dev/dm-3. Logical volume resize_matrix/resize_lv successfully resized. [root@virt-557 ~]# echo $? 0 Version-Release number of selected component (if applicable): kernel-5.14.0-239.el9 BUILT: Thu Jan 19 04:29:56 PM CET 2023 lvm2-2.03.17-4.el9 BUILT: Tue Jan 10 06:40:12 PM CET 2023 lvm2-libs-2.03.17-4.el9 BUILT: Tue Jan 10 06:40:12 PM CET 2023
> # lvextend --yes --fs resize -L +446M resize_matrix/resize_lv > Rounding size to boundary between physical extents: 448.00 MiB. > Size of logical volume resize_matrix/resize_lv changed from 30.00 GiB (7680 extents) to <30.44 GiB (7792 extents). > Cannot find active LUKS dm-crypt device using resize_matrix/resize_lv. > File system extend error. > Logical volume resize_matrix/resize_lv successfully resized. > # echo $? > 5 This is not ideal and can be improved. lvextend --resizefs should fail in the case where crypto_LUKS is seen on the LV, but the crypt device is missing. Failing is correct because the user requested resizefs, but lvextend is unable to do it. (It's unable to even look for a fs when the crypt device is missing, but we assume there would be a fs there since the user has requested resizing it.) In the example above, lvextend would ideally fail before extending the LV. That's not always possible for resizefs, but when it is possible it's the preferred behavior. In this case we can easily do that, and with that fixed, the example looks like this: $ echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/test/foo $ echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/test/foo foocr $ cryptsetup luksClose foocr $ lvextend -L+32M --resizefs test/foo LUKS dm-crypt device must be active for fs resize. $ echo $? 5
fixed in main https://sourceware.org/git/?p=lvm2.git;a=commit;h=d9f8acb65a78c20ac806efaeb7a1e39208e1a443
*** Bug 2165771 has been marked as a duplicate of this bug. ***
Marking Verified:Tested in the latest rpms. kernel-5.14.0-306.el9 BUILT: Sat Apr 29 05:45:15 PM CEST 2023 lvm2-2.03.21-1.el9 BUILT: Fri Apr 21 02:33:33 PM CEST 2023 lvm2-libs-2.03.21-1.el9 BUILT: Fri Apr 21 02:33:33 PM CEST 2023 lvcreate --yes --type striped -n resize_lv -L 30G -i 2 resize_matrix Using default stripesize 64.00 KiB. Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Logical volume "resize_lv" created. 'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv' 'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks' 'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks' deactivating LV resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvchange --yes -an resize_matrix/resize_lv Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvextend --yes --fs resize -L +420M resize_matrix/resize_lv Logical volume resize_matrix/resize_lv must be active for file system resize. activating LV resize_lv -ay on grant-01.6a2m.lab.eng.bos.redhat.com lvchange --yes -ay resize_matrix/resize_lv Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvextend --yes --fs resize -L +519M resize_matrix/resize_lv LUKS dm-crypt device must be active for fs resize. PRE:31457280.0 POST:31457280.0 lvremove -f resize_matrix/resize_lv Logical volume "resize_lv" successfully removed.
Works in the latest build as well. Marking VERIFIED. kernel-5.14.0-306.el9 BUILT: Sat Apr 29 05:45:15 PM CEST 2023 lvm2-2.03.21-2.el9 BUILT: Thu May 25 12:03:04 AM CEST 2023 lvm2-libs-2.03.21-2.el9 BUILT: Thu May 25 12:03:04 AM CEST 2023 ------------------------------------------------------------ lvcreate --yes --type raid1 -n resize_lv -L 30G -m 2 resize_matrix Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv. Logical volume "resize_lv" created. lvconvert --yes --raidintegrity y resize_matrix/resize_lv Using integrity block size 512 for unknown file system block size, logical block size 512, physical block size 4096. Logical volume resize_matrix/resize_lv has added integrity. 'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv' 'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks' 'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks' deactivating LV resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvchange --yes -an resize_matrix/resize_lv Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvextend --yes --fs resize -L +602M resize_matrix/resize_lv Logical volume resize_matrix/resize_lv must be active for file system resize. activating LV resize_lv -ay on grant-01.6a2m.lab.eng.bos.redhat.com lvchange --yes -ay resize_matrix/resize_lv Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com lvextend --yes --fs resize -L +557M resize_matrix/resize_lv LUKS dm-crypt device must be active for fs resize. PRE:31457280.0 POST:31457280.0 lvremove -f resize_matrix/resize_lv Logical volume "resize_lv" successfully removed.