Ubuntu – Resizing LUKS partition when not using LVM

lukspartitioning

I previously had two partitions on my hard disk, /dev/sdb1 and /dev/sdb2. sdb1 was unencrypted and sdb2 is encrypted with LUKS. I deleted sdb1 and would now like to resize sdb2 to take the space previously occupied by sdb1. How do I do this without destroying my data?

Cryptsetup has option called resize. What does this do? Can I just use it to enlarge the LUKS container to take all the space on the disk, then open the container and resize the underlying ext4 filesystem as I would normally do? The problem with this is that I normally use gparted to do things like this but gparted doesn't support resizing LUKS and I don't know how to do it with other tools.

Best Answer

  • Use gparted to move the partition all the way to the left, then you can use command line parted to resize the partition, then it sounds like you can use the cryptsetup resize option to enlarge the encrypted container, then finally resize2fs to enlarge the filesystem in it.

  • Related Question