Increasing the size of a LUKS cryptfs partition
by morecode
Warning: This guide assumes that the partition you’re expanding into is adjacent to a pool of free space. Things get a bit trickier if that isn’t the case (re-arranging your partitions is probably necessary).
The system that I performed this on: Fedora 16 KDE install, on a 120GB SSD installation (migrated from an 80GB SSD using Acronis True Image). Fedora doesn’t set encryption up via LVM in the installer, seemingly opting for a plain vanilla container.
Step 0: Boot into a live CD environment. I used a Fedora 16 KDE respin CD which had all these tools. Open a console (in KDE this was `konsole`).
Step 1: Blow away the partition itself. You’ll need to do this with `fdisk`. Make a new partition, with the cluster of free space included. Select Linux for type when prompted (usually 82 OR 83). Write changes to disk.
Step 2: Open your crypted filesystem:
<code>
# Replace /dev/sda2 with your own filesystem
# cryptsetup luksOpen /dev/sda2 root
</code>
Step 3: Expand the crypted FS
<code>
# cryptsetup resize root
# e2fsck -f /dev/mapper/root
# resize2fs -p /dev/mapper/root
</code>
Step 4: Safety hat
<code>
# cryptsetup luksClose root
# sync; sync; reboot
</code>