2

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.

1

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.

|improve this answer|||||
  • 2
    It doesn't seem to be possible to move LUKS partitions with gparted. – Echows Nov 20 '15 at 8:34
  • @Echows, that's odd.. it should at least be able to move it.. are you using the latest version? Don't forget you have to unmount the encrypted container first, including cryptsetup close. – psusi Nov 21 '15 at 0:03
  • 1
    I'm using the version in Ubuntu 15.10 repository which seems to be 0.19.0. In the information window for the partition it simply says "Linux Unified Key Setup encryption is not yet supported". It basically doesn't let me do anything to the partition. – Echows Nov 22 '15 at 16:22
  • Perfect answer! Worked like a charm.\\ Of course the area has to be unmounted and unmapped by luksClose! \\ First I booted into a different Linux. Then I enlarged with gparted (0.30.0 on Fedora27). GParted recognises the LUKS correctly \\ cryptsetup resize only works after mapping the device, see man page! and it works perfect. \\ finally do resize2fs on the device (represented by the mapping). Asks for a e2fsck first, fine! \\ brilliant work. no trouble. Encryption with LUKS is really easy. Thanks user psusi for the hints! – opinion_no9 Nov 22 '17 at 7:51
0

KDE Partition Manager 2.2.0 can resize LUKS partitions, so you won't need to deal with partition sizes manually.

It is not packaged for Ubuntu yet, but you can try to compile kpmcore 2.2.0 and then partitionmanager 2.2.0 yourself (which is probably less risky than resizing partitions manually).

Or alternatively you can try some LiveCD's of distributions that have already packaged kpmcore/kde partition manager 2.2.0. E.g. Neon which is based on Ubuntu LTS.

|improve this answer|||||
0

GParted 0.28 (released on February 2017) adds support for resizing file systems inside open LUKS volumes.

Currently no Ubuntu release ships that version, but it is simple to install from source, as the packaged version of libparted2 is recent enough for it to work. A apt-get build-dep gparted would give you the dependencies needed (plus apt-get install gnome-common if you need to (re)generate the configure script).

[1] http://gparted.org/news.php?item=207

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.