10

I have a 1TB (or thereabouts) SSD drive on my laptop, on which is installed Ubuntu 14.04.

I want to increase the size of the boot partition, so I've booted from a live CD, and ran GParted.

I have two partitions - the main one, /dev/sda2, and the boot one, /dev/sda1. Within /dev/sda2 is an encrypted partition called /dev/sda5. It looks like this:

enter image description here

I can right click on /dev/sda2, and choose "Resize/Move", but on the following dialog it doesn't let me make any changes.

Is this because I would need to shrink the encrypted partition within /dev/sda2 first, and you can't resize encrypted partitions? That seems plausible but my knowledge runs out at this point.

Fabby
  • 34,259
Max Williams
  • 227
  • 1
  • 3
  • 12

3 Answers3

3

The partition/dev/sda2 is an extended partition under which the logical partition /dev/sda5 was created. Although this would not have been necessary for the setup being shown in the screenshot you've provided, the reason to create an extended partition is to achieve the possibility to create more than three additional partitions later on. It is not possible to create more than four primary partitions on a disk with msdos (MBR) partition table. But now to your question : you can - and have to - resize the partition /dev/sda5. First decrypt this partition and then start the resizing process with GParted ...

  • Shrink /dev/sda5 (make all free space to be preceding space)
  • Shrink /dev/sda2 (make all free space to be preceding space)
  • Grow /dev/sda1 (add the complete free unallocated space)

It is important that afterwards no free unallocated space is left between /dev/sda1 and /dev/sda2,
which means that you may need to add 1 MB still remaining space to /dev/sda1 or to /dev/sda2.
I've tested it in a virtual machine, but I recommend to backup the disk in case something goes wrong.
Find more information about partition resizing and what you have to pay attention to : GParted Manual

cl-netbox
  • 31,163
  • 7
  • 94
  • 131
  • 1
    Hi Max, what I wrote was the answer addressing your question, but what I recommend is something different. Ubuntu 14.04 is nearing EOL and the whole setup is not "the most professional one". So, I would backup the personal data and then start over from scratch - first create a new partition table, then create a new partition, format it with ext4 and then install Ubuntu 18.04.1 LTS ... adjust your individual configuration from within the Ubuntu installer. Once the installation process has finished, boot the system and restore back your data. :) – cl-netbox Sep 03 '18 at 17:49
  • Thanks @cl-netbox but I actually want to stick with 14.04 to replicate our work server environment. WRT your answer, can I decrypt it in place? Or would I need to decrypt it to another HDD, say? – Max Williams Sep 03 '18 at 20:20
  • 2
    @MaxWilliams Yes, you can decrypt the partition "in place", there is no need to move something. After having tested the resizing process in a virtual machine, I updated the answer with the relevant steps. :) – cl-netbox Sep 04 '18 at 10:00
  • @cl-netbox Following this answer, and using Gparted Live, I unlock and try to shrink the lvm2 partition (called sda5 for me), but the resize dialog doesn't allow me to adjust the settings in it. Any suggestions? – BPugh Mar 23 '20 at 01:59
  • @BPugh You may want to read How can I resize a LVM partition? ... :) – cl-netbox Mar 23 '20 at 11:35
  • How do I decrypt the partition within Gparted? Actually, my encrypted partition is the one I'm working on. Seems like I'd have to flash a USB to be able to change its size then, since it can't be mounted while being modified anyway, isn't it so? – Andreas L. Dec 15 '20 at 17:45
  • 2
    Exactly @AndreasL. ! You can't modify mounted system partitions ... boot from a GParted USB drive. :) – cl-netbox Dec 15 '20 at 18:14
3

I found a much easier solution. Run Xubuntu live, install and launch partitionmanager. It can very well handle encrypted partitions.

Complete details are here: http://e1z.ca/devlog/encrypted_partition_resize.html

PC.
  • 199
  • Ah, sounds promising. I will investigate when my in-tray stops being on fire - thanks! – Max Williams May 30 '19 at 09:51
  • Except that there is no 'decrypt' option in partitionmanager now. I just installed it from a Mint 20.2 live usb, and a right-click on my encrypted partition shows no decrypt option. Is there something special has to be done beyond running it sudo? – Peter Flynn Aug 27 '21 at 19:21
  • The URL is broken. :( – Gabriel Staples Dec 16 '22 at 22:24
  • The instructions were simple. Install Xubuntu live on a pendrive. Boot your system from the pen drive. You will have the option to install & launch partitionmanager. The simple point to notice is that you wont be able to rezise encrypted partion if Linux is booted from the same partition. All you need is an external system and any standard partitioning manager should be able to resize the disks. – PC. Dec 24 '22 at 08:19
0

GParted won't seem to let me shrink an encrypted partition

I had the same problem as just this title of the question implies.

My problem was that GParted does not allow you shrink an outer LUKS-encrypted partition until first the inner LVM volumes within it are shrunk! To do that, you have to use Gnome Disks to unlock the outer LUKS-encrypted partition, and then blivet-gui to shrink the inner LVM volumes within it. Once that is done, you go to GParted and shrink the outer LUKS-encrypted partition. All 3 tools are required.

See my detailed instructions and screenshots here. It took me quite a bit of time to figure this out: Unix & Linux: Unlock a LUKS-encrypted outer partition, shrink and edit the LVM volume(s) within it, and then shrink the outer LUKS partition using a combination of 3 GUIs: Gnome "Disks", "blivet-gui", and "GParted".