0

I have a LUKs-on-LVM setup. I'm trying to lvresize, so I can remove a pv. However, I keep getting an error:

Cannot find active LUKS dm-crypt device using my_vg/luks_lv.


More information:

My setup:

my_vg: 6TB

  • luks_lv: 6TB (6TB ext4)
    • small_pv1: 3TB
    • small_pv2: 3TB

I added a new large drive.

my_vg: 12 TB

  • luks_lv: 12 TB (12TB ext4)
    • small_pv1: 3 TB
    • small_pv2: 3 TB
    • big_pv3: 6 TB

I want to move all extents from small_pv1 to the other pvs. Then remove small_pv1 from the vg. So, first I shrank the ext4 filesystem with resize2fs.

my_vg: 12 TB

  • luks_lv: 12 TB (8TB ext4)
    • small_pv1: 3 TB
    • small_pv2: 3 TB
    • big_pv3: 6 TB

I plan to expand the lv and file system to take up the entire vg after I remove the pv.

I thought I needed to resize the luks_lv LUKS partition using cryptsetup resize. This didn't seem to do anything. Then I saw this post, which said that was unnecessary, since I would use cryptsetup luksClose before doing lvresize.

So I tried lvresize --size 8500G /dev/my_vg/luks_lv. However, I got this error:

Cannot find active LUKS dm-crypt device using my_vg/luks_lv.

cryptsetup status /dev/my_vg/luks_lv returns:

/dev/my_vg/luks_lv is active.

I can still decrypt and mount luks_lv. The file system was resized as expected, but the lv still spans the entire vg.

Again, my ultimate goal is:

my_vg: 9 TB

  • luks_lv: 9 TB (9TB ext4*)
    • small_pv2: 3 TB
    • big_pv3: 6 TB

*I know I can't get exactly 9TB because LUKS will need some space.

What is going on and how do I fix this? Thanks.


Edit: Adding information requested by @telcoM

lsblk returns:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdc 8:32 0 2.7T 0 disk
- my_vg-luks_lv 254:1 0 10.9T 0 lvm
sdd 8:48 0 5.5T 0 disk
- my_vg-luks_lv 254:1 0 10.9T 0 lvm
sde 8:64 0 2.7T 0 disk
- my_vg-luks_lv 254:1 0 10.9T 0 lvm

*I used whole numbers in my initial question for simplicity.

Edit 2:

I'm running Arch Linux: cryptsetup 2.6.1-3, linux 6.5.4.arch-1, lvm2 2.03.22-2.

1
  • Maybe don't use lvresize, but lvextend (which should require you to resize the crypt on the lv and then the fs on the crypt manually afterwards; also better do the first two steps with the crypt closed and the final step with the fs unmounted)
    – Tom Yan
    Sep 30, 2023 at 13:36

1 Answer 1

0

So I tried lvresize --size 8500G /dev/my_vg/luks_lv. However, I got this error:

Cannot find active LUKS dm-crypt device using my_vg/luks_lv.

This seems implausible - LVM tools should not even look for dm-crypt devices. Was the actual command cryptsetup resize --size 8500G /dev/my_vg/luks_lv?


cryptsetup resize wants the name of the crypto mapping (i.e. what you are using to mount the encrypted filesystem), not of the underlying device (which is a LV in this case).

This is different from cryptsetup status which may be able to accept either of those.

In other words, if you are doing something like:

cryptsetup open /dev/my_vg/luks_lv my_crypt --type luks
mount /dev/mapper/my_crypt /where/ever

then cryptsetup resize will want something like:

cryptsetup resize --device-size 8300G my_crypt
lvresize --size 8500G /dev/my_vg/luks_lv

If you still have problems, please show the outputs of lvdisplay -m my_vg/luks_lv and the relevant lines of dmsetup ls --tree -o blkdevname or lsblk.

3
  • Edited OP with info you requested. The command was definitely lvresize. I tried cryptsetup resize as you suggested. That changed the size of the LUKS container. However, lvresize (while LUKS container is open) gives me a strange error: "File system size 330695704576b is adjusted for crypt data offset 16777216b. File system ext4+crypto_LUKS found on my_vg/luks_lv. File system size (8.00 TiB) is larger than the requested size (307.98 GiB). File system reduce is required (see resize2fs or --resizefs.)." I still get the same dm-crypt cannot be found error running lvresize with LUKS closed.
    – Teatree
    Sep 30, 2023 at 15:40
  • Your lvresize might be of newer version or otherwise more integrated with the dm-crypt tools (and maybe even with filesystem resizing tools?) than I have experience of. You may be using bleeding-edge software, so please add the name and version of your Linux distribution to your question post, as it might be important.
    – telcoM
    Sep 30, 2023 at 21:53
  • I'm running Arch Linux: cryptsetup 2.6.1-3, linux 6.5.4.arch-1, lvm2 2.03.22-2.
    – Teatree
    Sep 30, 2023 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .