3

Here's my setup

$ lsblk
NAME                   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nvme0n1                259:0    0 238.5G  0 disk
├─nvme0n1p1            259:1    0   100M  0 part  /boot/efi
├─nvme0n1p2            259:2    0   250M  0 part  /boot
└─nvme0n1p3            259:3    0 238.1G  0 part
  └─Be-Water-My-Friend 254:0    0 238.1G  0 crypt
    ├─Arch-swap        254:1    0     2G  0 lvm   [SWAP]
    └─Arch-root        254:2    0 236.1G  0 lvm   /

I have one main LUKS2-encrypted partition (nvme0n1p3), with one LVM volume group (Be-Water-My-Friend) containing two logical volumes Arch-swap and Arch-root.

The Arch-root is a btrfs.

When I set that up, I only chose 2GB of swap which turns out to be insufficient for my needs. I would like to increase that to 24GB of swap.

For that, I think I need to

  1. boot on a USB live key
  2. decrypt the LUKS2 partition
  3. mount the Arch-root volume
  4. shrink the Arch-root file system with
    btrfs filesystem resize -22g
    
  5. remove the Arch-swap logical volume
  6. recreate the Arch-swap logical volume taking all available space in the Be-Water-My-Friend volume group.

Is there anything I'm missing? I really don't want to screw that up!

1
  • Because it’s LVM, you don’t need to recreate the swap volume here. You can just resize it in place and then run mkswap with the correct UUID option to update things. The nonlinear nature of the resultant LV might be a (small) performance issue on rotational media, but it just won’t matter on an SSD. Commented Jul 20, 2021 at 22:22

2 Answers 2

5

You need one extra step between 4 and 5 -- shrink the Arch-root logical volume using lvresize -L-22G Arch/root (lvresize has option --resizefs to resize both the LV and the filesystem, but it currently doesn't support btrfs so you can't use it here). This answer nicely explains difference between resizing filesystem (btrfs in your case) and the block device (LVM logical volume).

You also might want to use --uuid with mkswap to set your old swap UUID for the new swap. Swaps are usually not referred with UUID in /etc/fstab and GRUB, but using the old UUID might save you some problems.

Also if you just want a bigger swap, you can create a swap file on btrfs and use it as second swap.

1
  • 1
    Oh waw did not know about swapfiles! Just created one now and this solved the issue immediately! I don't want to get into trouble trying to resizing everything so the swapfile solution works for me just fine. Thanks a lot! Commented Jul 20, 2021 at 14:54
4

A small correction:

Step 2 should be: unlock the LUKS2 partition (with a cryptsetup open --type luks ... or equivalent command).

Step 2.5 should be added: verify the presence of the Arch volume group and ensure it's been activated, with e.g. vgscan; vgchange -ay Arch. (Depending on which live media you're using, the system may or may not auto-activate the VG as the encrypted partition is unlocked.)

Step 4.5 should be added: shrink the LV after you're sure the filesystem inside it has been successfully shrunk:

lvresize -L-22G Arch/root

Also, Be-Water-My-Friend is the name throuch which the encrypted device is accessed, and thus also the name of the LVM Physical Volume (/dev/mapper/Be-Water-My-Friend).

The name of the LVM volume group is simply Arch. In lsblk listing, the names of LVM Logical Volumes are presented in the form VGname-LVname, so e.g. Arch-swap means logical volume swap in volume group Arch.

If the VG/LV name includes hyphens (minus signs), those will be doubled to distinguish from the single hyphen that acts as a delimiter between the names of the VG and the LV.

You must log in to answer this question.

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