If I create an encrypted partition using cryptsetup
cryptsetup -q luksFormat /dev/vdb3 /tmp/pwfile
cryptsetup -d /tmp/pwfile luksOpen /dev/vdb3 pv00
and setup a nested gpt partition table on /dev/mapper/pv00
parted=/sbin/parted
disk=/dev/mapper/pv00
${parted} -s -- "${disk}" mklabel gpt
${parted} -s -- "${disk}" mkpart root 0% "${endp1}GiB"
${parted} -s -- "${disk}" mkpart swap "${endp1}GiB" "${endp2}GiB"
${parted} -s -- "${disk}" mkpart none "${endp2}GiB" "${endp3}GiB"
${parted} -s -- "${disk}" mkpart export "${endp3}GiB" 100%
then the new partitions are listed by lsblk
as expected
root@clone:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 254:0 0 8G 0 disk
`-vda1 254:1 0 8G 0 part /
vdb 254:16 0 128G 0 disk
|-vdb1 254:17 0 126M 0 part
|-vdb2 254:18 0 897M 0 part
`-vdb3 254:19 0 120.6G 0 part
`-pv00 252:0 0 120.6G 0 crypt
|-pv00p1 252:1 0 8G 0 part
|-pv00p2 252:2 0 8G 0 part
|-pv00p3 252:3 0 8G 0 part
`-pv00p4 252:4 0 90.6G 0 part
but I cannot close the encrypted partition anymore:
root@clone:~# cryptsetup luksClose pv00
Device pv00 is still in use.
dmsetup info -C
shows the nested partitions are not used, but /dev/mapper/pv00 is:
# dmsetup info -C
Name Maj Min Stat Open Targ Event UUID
pv00 252 0 L--w 4 1 0 CRYPT-LUKS2-f2a811407807491b875f414fa61f854d-pv00
pv00p1 252 1 L--w 0 1 0 part1-CRYPT-LUKS2-f2a811407807491b875f414fa61f854d-pv00
pv00p2 252 2 L--w 0 1 0 part2-CRYPT-LUKS2-f2a811407807491b875f414fa61f854d-pv00
pv00p3 252 3 L--w 0 1 0 part3-CRYPT-LUKS2-f2a811407807491b875f414fa61f854d-pv00
pv00p4 252 4 L--w 0 1 0 part4-CRYPT-LUKS2-f2a811407807491b875f414fa61f854d-pv00
AFAIU the nested partitions keep pv00 busy.
Using lvm2 instead of a nested gpt partition table there is no such problem. I can deactivate the volume group using vgchange -an vg00
, and pv00 can be closed as expected. Is there a similar command to decommission the nested gpt partition table on /dev/mapper/pv00 without removing it?