Is it possible to shrink an encrypted partition?

I want to shrink a partition so that I can install another distro for a dual boot system. Is this possible? I’ve tried with gparted but it won’t allow me to resize a LUKS encrypted partition.

Yes, it is possible, but dataloss is just one tiny typo away, so backup first.
The procedure I used was quite manual and does not allow for a change of the beginning of a partition, but the end worked fine.
First, unmount the filesystem, but keep it open in cryptsetup.
Then, shrink the filesystem using your favorite tool, for example resize2fs for ext4.
Now it is time to use cryptsetup to close the luks handle.
The next step is to destroy and recreate the partition (let’s say /dev/sda3). For this you can use fdisk. Before deleting the partition, check where the start is and write down that number. Then, delete the partition and create a new one starting at exactly the same block/cylinder. It is crucial to have the exact start and a size which is at least the size of the filesystem which you chose with resize2fs (sligthly larger is easier, use resize2fs afterwards to expand the filesystem to use the entire partition).
Now you are done, the partition can be unlocked by cryptsetup and mounted with mount, everything should work fine (did for me anyways).

One reminder: If you change the beginning of the partition (in fdisk), then the luks header will be unusable and the filesystem cannot be decrypted -> all data is lost. So, be careful!

1 Like

See here:

https://ask.fedoraproject.org/search?q=Resize%20lvm