0

I need to resize LVM on LUKS on Debian to take space from home and give it to var.

└─sda5               8:5    0   931G  0 part  
  └─sda5_crypt     253:0    0   931G  0 crypt 
    ├─my-vg-root   253:1    0  23.3G  0 lvm   /
    ├─my-vg-var    253:2    0   9.3G  0 lvm   /var
    ├─my-vg-swap_1 253:3    0   976M  0 lvm   [SWAP]
    ├─my-vg-tmp    253:4    0   1.9G  0 lvm   /tmp
    └─my-vg-home   253:5    0 802.8G  0 lvm   /home

I'm following the ResizeEncryptedPartitions tutorial:

  1. Boot the desktop, live CD. Install & configure the tools (lvm2 and cryptsetup).
  2. Reduce the (root) file system with resize2fs.
  3. Reduce the (root) (LVM) Logical Volume with lvreduce.
  4. Reduce the (LVM) Physical Volume with pvresize.
  5. Reduce the Crypt with cryptsetup.
  6. Reboot to reduce the Partition storing the crypt with fdisk.

The tutorial continues, instructing the reverse,

Detailed resizing ~ Enlarging an encrypted partition This section will be shorter, it is basically the reverse of the above.

My question. Do I need to reduce the (LVM) Physical Volume #4 and reduce the Crypt #5, if I'm giving this space over to another partition?

The tutorial gives a reason for resizing the LVM Physical Volume

Resize your (LVM) Physical Volume. The physical volume used by LVM can become "fragmented" in that the (LVM) Logical Volumes within the (LVM) Physical Volume are not always in order. There is no defragmentation tool, so if you may need to manually move the logical partitions (back up the data, delete the (LVM) Logical Volume, re-create a replacement (LVM) Logical Volume, restore data from backup).

I'm thinking of taking home down, 800g-200g and var up 9-200g, and leave 400g free to move later depending on how they both fill up.

I get the idea--delete my swap and tmp LVM partitions, then change the var size. I guess the article seems more generic, and so I'm asking here about my particular case.

Also on SE: Resize an existing LVM partition and add the space to another LVM partition

1 Answer 1

2

You don't need to resize the LVM physical volume or the LUKS device or the partition, if everything you want is to "move" some space from the /home logical volume to /var logical volume, you'll be working only on the logical volume level.

Your steps will be (from a LiveCD, you'll need to unlock the encrypted drive first either from the file manager or manually with cryptsetup):

lvreduce --resizefs -L 200g my-vg/home

to reduce /home to 200 GiB, --resizefs will take care of resizing the filesystem and

lvextend --resizefs -L 200g my-vg/var

to grow /var to 200 GiB. And that's all.

As always, something can go wrong with storage operation so backing up your data is recommended.

3
  • Then this one line: lvextend --resizefs replaces the four steps in my original linked tutorial? pvchange (unlock PV) -> lvresize -> pvchange (relock) -> resize2fs
    – xtian
    Apr 25, 2021 at 15:39
  • BTW. Success. I used your shortcut and found a reference at Arch for Resizing the logical volume and file system in one go. This tutorial uses lvresize, so I guess lvextend is syntactic sugar for the same...
    – xtian
    Apr 25, 2021 at 18:39
  • 1
    The part with pvresize and using cryptsetup resize from the linked howto in your question apply only when you want to resize the underlying partition, if you only want to resize the logical volumes lvresize (yes, lvextend and lvreduce are just "helper" commands, I like to use these because they protect against accidentally shrinking or growing the LV if you want to do the opposite). Apr 25, 2021 at 19:00

You must log in to answer this question.

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