Resizing a LVM inside a LUKS Crypt

I made a mistake. A pretty big mistake.


When I was setting up my new workstation at my new job, I encrypted the filesystem, as is smart when you’re going to be putting an entire codebase on it. The problem was that I accepted Debian 8’s defaults for the drive I was installing it on when I partitioned out separate /home and / (root) partitions. Therefore, I got the following:

Now 9.3G is pretty easy to fill up with installed applications, libraries, etc–especially when you’re building programs from source in 5 or more different languages, and multiple versions of said languages (Thanks, Java). I had about 300MB left on / when I bit the bullet and had to do something about it.

Ultimately, the process is not hard, so fear not. There’s also little risk of messing anything up or breaking your filesystem, at least in my case. I had a 13GB swap partition, but my workstation has 32GB of DDR4 in it–so I don’t even need the swap. This makes a very long process of shrinking /home, expanding [SWAP], shrinking [SWAP], and finally expanding / (root) into a very, very simple process: delete swap, expand root. LVMs are made to be resized easily, and since my crypt was already at its max size, I didn’t have to even boot into a live CD–I did the entire resize live in Debian.

I did, however, make a full backup of my disk just in case using Clonezilla. I’m not going to go into detail on how to set that all up because their documentation is very extensive for even odd use cases (like mounting NTFS drives, like I had to).

Once you’re backed up and booted into your box, open up a terminal, and just follow these steps. You should run a lsblk to make sure you know your volume names. Every thing beyond this point you should make sure you’re touching the right stuff.

Resizing a LVM inside LUKS Crypt

1. Become root:

2. Show your block-level devices

3. Show your logical volumes (In my case, the ones starting with hanlonn-deb1 are the ones we’re looking at)

4. Turn off swap

5, Remove swap_1 Logical Volume

6. Resize root to take up 100% of the remaining free space (all of the swap we just removed)

7. Resize the filesystem for / (root) online

8. Check to make sure the disk/filesystem was successfully resized and at the correct size.

9. Check out your new lsblk

That’s almost it! The new lsblk should output something like this:


The final step is to edit /etc/fstab using your favorite editor (I like vim), and remove the line that is used to mount your swap partition. It’s the one that will reference the same name (/dev/mapper/…) you used in step 5.

Do a reboot to make sure everything comes up okay once you’ve edited fstab. I had my sda3 partition fsck (filesystem check) when I rebooted, but it was quick and didn’t find any errors, so your mileage may vary.


The seemingly impossible task of resizing a LVM inside a LUKS crypt is finished. If anything goes wrong, you can of course just restore from the backup you made (you did make a backup, right?) and try again. There’s no fussing about with partition tables, so this one should be pretty hard to mess up.

Tags :