Resize an Encrypted Partition without Breaking your Linux System

TL;DR: boot off of install medium; decrypt system drive via command line; use gparted to resize the now decrypted partition

So you have a multi-boot or multi-partition Linux computing system, and you’ve encrypted it with LUKS encryption. Good work! Sometimes you’ll have a system running a Linux distro along with Windows on the same physical hard drive. If you’re running out of space on the Windows partition and need to shrink your Linux partition to make room, this article will show you how to do it.

Now you need to resize one of those encrypted partitions, so you fire up gparted or the like and attempt to resize the partition you’re currently running in.. wait,, that’s not going to work. So, you shut down your machine and boot off the install medium. In my case, I’m using Arch Linux based Manjaro Linux, so I’ll boot my system off of the USB thumb drive I used for initial install.

Once you’re running off the USB drive, get root on the install medium, which should be as easy as:

$ sudo su -

No password required.. now I can access the contents of my internal system drive… a little too easily… hmm.. see the value of encrypting your hard drives!

Let’s take a look at the file systems of the attached hard drives with:

# lsblk

This will let us know what the file system layout and naming looks like. The main internal system drive will usually be sda and the partions sda1, sda2, etc.

You will be able to tell which partition is encrypted and you’ll need that information for the next step in the process.

# cryptsetup luksOpen /dev/sda<proper-number-based-on-your-system-goes-here> cryptdisk

For me it would be:

# cryptsetup luksOpen /dev/sda2 cryptdisk

Then you’ll be prompted to enter the decryption key. After successful decryption, you’ll have root access to your now decrypted system drive. You can simply run gparted as root from the terminal and use the GUI to resize the partition.

That’s it. I hope you found this helpful.

Best,
Tim Beach

The section below includes feedback from readers.

As “loan M San” points out:

For those of you running LUKS encrypted partitions GParted won’t work. There’s an alternative method using partition manager as detailed here: http://e1z.ca/devlog/encrypted_partition_resize.html

I don’t agree with this, and I think the point is being missed. You have to first decrypt the encrypted partion(s), then you can use gparted.. or really anything else. I wrote this article because I solved this problem for my own systems and didn’t find anywhere online that explained the process. 
The basic idea that you can take with you anywhere is this: 
 — Make a bootable USB drive from a Linux ISO. In this case GParted has available ISOs that work
 — Boot system from external thumb drive
 — Open terminal once external system boots, and use terminal to decrypt the encrypted partition(s)
 — Then run whatever you want to resize, etc

I hope that helps to clarify. While gparted doesn’t support encrypted volumes, that’s not the point. The point is, first decrypt, then resize :-)