Shrinking LVM over LUKS over LVM

I have partitioned my sda4 as LVM-over-LUKS-over-LVM:

  1. On /dev/sda4 I created volume group “levelone” and logical volume “opensuse”
  2. On “opensuse” logical volume, I created a LUKS partition
  3. On the LUKS partition, I created volume group “leveltwo” and logical volumes “root,” “swap,” and “home”

Here is the result of lsblk related to sda4:


├─sda4                       8:4    0   800G  0 part  
│ └─levelone-opensuse      254:0    0   800G  0 lvm   
│   └─cr_opensuse          254:1    0   800G  0 crypt 
│     ├─leveltwo-root      254:2    0    40G  0 lvm   /
│     ├─leveltwo-swap      254:3    0     8G  0 lvm   [SWAP]
│     └─leveltwo-home      254:4    0   740G  0 lvm   /home

Now I want to create another logical volume called “archlinux” under “levelone” volume group, and I need some extra space which should be taken from “home” logical volume. What is the correct procedure to shrink “home” all the way up to “levelone” volume group?

You need to shrink the filesystem on leveltwo-home first. I guess it spans the whole volume, right? Generally, one of the points in favour of lvm is that you do not have to fix final size at creation time - in contrast to partitioning. So always start with a reasonably low volume size and increase as needed.

I’m pretty new to all this, you know. Please be more detailed if possible.

Depends on the filesystem used.

https://www.suse.com/documentation/sles-12/singlehtml/stor_admin/stor_admin.html#cha.resize_fs

Now, if you chose xfs for home, which I think is Opensuse’s default, you are probably out of luck. I rarely use xfs and only get that with Red Hat installations where the admins created small volumes that are supposed to grow.

There always is the option to backup home, delete the volume, create a new smaller volume, and restore the data. Since shrinking is kind of dangerous, you would have to create a backup anyway, so why bother with shrinking and simply do the backup/restore thing. You do have backups, right?

And if you do that, you could reconsider the layout of your lvm. Unless you want different crypt keys per installation, why not move crypt up one level and then create vg per installation? That is what I would do. But then, I do not see the point of having multiple installations on the same hardware. Choose one and have the other(s) virtual. The differences between distributions are really minor, so why have two roots with essentially the same data?

Also, if you want to learn, do that in virtual machines. Much easier to back out of bad choices there :wink: