Error trying to resize encrypted partition

On a GPT system, I have installed Windows and EndeavourOS just fine.

sda7 is the encrypted root partition, /home is on a separate partition.When I boot into live mode, I tried to decrypt the partition (both through gparted and through the terminal via this command sudo cryptsetup luksOpen /dev/sda7 crypt and it can decrypt, but when I want to shrink the size, I keep getting an error.

I have saved the error details.

GParted 1.1.0

configuration --enable-libparted-dmraid --enable-online-resize

libparted 3.3


Device:	/dev/sda
Serial:	VB4cf33815-e6a551f0
Sector size:	512
Total sectors:	104857600
Heads:	255
Sectors/track:	2
Cylinders:	205603
Partition table:	gpt
Partition	Type	Start	End	Flags	Partition Name	File System	Label	Mount Point
/dev/sda1	Primary	2048	1085439	hidden, diag	Basic data partition	ntfs	Recovery	
/dev/sda2	Primary	1085440	1288191	boot, esp	EFI system partition	fat32		
/dev/sda3	Primary	1288192	1320959	msftres	Microsoft reserved partition	unknown		
/dev/sda4	Primary	1320960	43149311	msftdata	Basic data partition	ntfs		
/dev/sda5	Primary	43149312	43354111			ext4	boot	
/dev/sda6	Primary	43354112	53932031			ext4	home	
/dev/sda7	Primary	53932032	104857566			luks		/dev/mapper/crypt

Device:	/dev/sdb
Serial:	VBa9187688-0f01b60f
Sector size:	512
Total sectors:	20971520
Heads:	255
Sectors/track:	2
Cylinders:	41120
Partition table:	msdos
Partition	Type	Start	End	Flags	Partition Name	File System	Label	Mount Point
/dev/sdb1	Primary	2048	4196351			linux-swap	swap	
/dev/sdb2	Primary	4196352	20971519			unknown		

Shrink /dev/sda7 from 24.28 GiB to 12.38 GiB  00:00:07    ( ERROR )
calibrate /dev/sda7  00:00:02    ( SUCCESS )
path: /dev/sda7 (partition)
start: 53932032
end: 104857566
size: 50925535 (24.28 GiB)
encryption path: /dev/mapper/crypt
check file system on /dev/mapper/crypt for errors and (if possible) fix them  00:00:05    ( SUCCESS )
e2fsck -f -y -v -C 0 '/dev/mapper/crypt'  00:00:05    ( SUCCESS )
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

221259 inodes used (13.88%, out of 1594320)
534 non-contiguous files (0.2%)
68 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 182615/96
1562683 blocks used (24.55%, out of 6365179)
0 bad blocks
1 large file

168775 regular files
13458 directories
0 character device files
0 block device files
0 fifos
2502 links
39012 symbolic links (38535 fast symbolic links)
5 sockets
223752 files
e2fsck 1.45.6 (20-Mar-2020)
shrink file system  00:00:00    ( ERROR )
resize2fs -p '/dev/mapper/crypt' 12984320K  00:00:00    ( ERROR )
resize2fs 1.45.6 (20-Mar-2020)
Please run 'e2fsck -f /dev/mapper/crypt' first.

This wasn’t happening before on an MBR partition table so I am not too sure why this is happening.

I couldn’t shrink , only expand a LUKS partition when it was open . Check the option help in Gparted , it has info about what it can do on a specific file system .

Did you shrink a partition or expand it ?

Edit : I am only talking about what I tried in Gparted . Expanding a closed LUKS partition of size 2GB to 4GB resulted in the partition half occupied i.e. 2GB full , 2GB available for me . Maybe I did wrong :man_shrugging:t2:

Oh wow I didn’t know. Isn’t there a way to shrink it at all?

I shrank it.

Edit: I am trying it on MBR now and same thing, maybe I got confused with something else. If so my bad then.

TLDR; => Try again from the EOS live environment!

You may have forgotten, but you had a similar question some time ago. ==>

The answer still applies - just leave out the “LVM” stuff.
Gparted should be able to do this for your simple ext4 in luks case. (Never tried this myself though; always do it via cli).

If not, try doing it manually. You can see the required commands in your error details.
If this still doesn’t work I could check your commands and/or provide the needed information.

But, in any case, do this from the EOS live environment (see below).

I think you misunderstood @Hystrix .
Of course you can shrink or grow luks partitions! You just need to make sure that the luks partitions filesystem isn’t mounted (“open”) during certain commands. It’s just advisable and sometimes required to shrink/grow from another environment, e. g. the EOS live environment.

Back then I was trying to encrypt both the home and the root partition and it stuffed up when I tried to reinstall the OS. At that time I was not trying to resize the partition.

I am not attempting to use LVM this time round though. Just normal luks encryption only for the root partition, not the home partition.


How would I resize this when it shows it is taking up maximum size?

Wait he will give you some useful commands . It’s better to update the live iso if you can . I once tried converting an ext4 partition to btrfs from live iso . It didn’t work because of a bug which was fixed in newer version .

Should I run sudo pacman -Syyu to update the entire OS, like do you mean I should update the entire OS in live mode?

You should only do that if you encounter any problems that did not happen in your current install ( an up to date system ) .

1 Like

Shrinking is a bit more complicated than growing.
Unfortunately I can’t help you with getting it done in Gparted. If you tried this and Gparted throws errors, well … (?)

I could however help you do this via cli.

But be warned, manipulating the partition table is always risky! Make sure you have backups of everything important on the whole sda drive. You could lose all other partitions on that drive. I will only help if you specifically assure me you have understood and are good with this :wink: .

You’ll basically have to do the following:

|          filesystem: EXT4                       |  (2)
|          LUKS partition: /dev/sda7              |  (1)

Steps to SHRINK the physical partition sda7 (1):

  1. shrink the ext4 filesystem (2) to minimal size
  2. resize (shrink) the LUKS container (1) to the size you desire
  3. grow the ext4 filesystem (2) to the new maximum size
  4. shrink the (crypt) physical partition /dev/sda7 (1)
  5. change partition table to reflect start and new end of (1)

Have you tried shrinking the EXT4 filesystem before shrinking the luks container?

Thanks mate.

Yes I am good with this :slight_smile:

I am a bit confused with this step, Do you mean /dev/sda7 as /dev/sda2 is my EFI boot partition as shown in this image.

Also I am a but confused between (crypt) physical partition and LUKS container. So the LUKS container is inside the (crypt) physical parition and the ext4 partition is inside the LUKS container?

May I know the commands for how to do this please?

Well through gparted after opening the LUKS partition, it shows that same partition as ext4 so I did try to resize it but then I get that error message.

This is the encrypted partition.

Sorry, yes I meant sda7!

Then it’s probably best to try doing it manually. I’ll have to get back to work in about half an hour though and would therefore like to postpone helping you out with some commands - don’t want to rush into some errors.
How time-critical is this resizing issue? Could we get back to it on Friday?



Yeah that sounds like a good idea. Hopefully it works.

THanks mate :slight_smile: I am doing this on a VM before I do this on actual hardware so it doesn’t really matter if it screws up.

Its not critical at all, its not something that I need to do now.

Yeah sure, take your time :slight_smile:, Thanks for your help mate :slight_smile: Enjoy your work if you can.

1 Like

Enjoy? Nah, it’s “work” :wink: .

Thanks, I’ll get back to you on Friday then …


Ah yeah I can understand how work can be stressful,

Thanks :slight_smile:

This is a bad idea.

Enbiggening a luks partition, and file system contained within, is risky and very prone to error.

Best way to resize a luks partition is to create a new partition of the correct size, luks encrypt it, create the file system, rsync your system / data into, then make any required config changes to allow it to boot.

You’ll need to edit crypttab, fstab, grub to use the UUIDs of your new luks partition and file system. You’ll also have to install grub again and manage your efi boot order.

Once it all works blow away the original partition.

I did this recently, relocated a bunch of my fully encrypted systems to a different SSD, using gparted, rsync and a text editor.

Much quicker, easier and reliable than reinstalling, only took about 90 mins for 3 systems. Most of that was ryncing and rebooting.

Good way to clone your system or even migrate your system onto a different file system (ie ext4 -> btfrs).

Let me know if you want any help at all.


Growing is actually much easier than shrinking.

Theoretically risky, yes … but I’ve never encountered an unrecoverable error in over a decade of resizing encrypted partitions.

If you have backups of important data, as you should, it’s so much faster resizing than recreating.

1 Like

That is why @2000 said to back up the data.

But what if I don’t have enough space on my drive (which is actually the case)? How would I be able to create a new partition then?

Copy to an external drive and replace your luks partition.

1 Like

AH I see

Not trying to sound rude or anything but I’d probably want to use @2000 method instead as that sounds more convenient, all though for the time being I will use your method, but as you and @2000 have suggested, I am going to make backups before proceeding, thanks anyways :slight_smile: