Reduce Swap Partition Size (LUKS)

I am using manjaro with full disk LUKS enabled during manjaro install.
It made encrypted main partition and encrypted swap partition.
I made a Swap Partition when my RAM was low.
Now I have doubled my RAM to 8 GB and the swap partition is barely used by Manjaro.
I want to reduce my swap partition size to 50% of what it is.

How to do it?

Thanks.

That are just general steps and might not be complete:

# Disable swap
sudo swapoff /dev/mapper/swap
# Unmount it
sudo umount /dev/mapper/swap
# Close it
sudo cryptsetup luksClose swap
# Set a new size of the partition
sudo cgdisk /dev/<device>
# Open the container again.
sudo cryptsetup luksOpen /dev/<device> swap
# Resize the container
sudo cryptsetup resize swap
# Recreate swap
sudo mkswap -f /dev/mapper/swap

Update /etc/crypttab and /etc/fstab if the UUID changed.

# Enable swap
sudo swapon /dev/mapper/swap
1 Like