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
Model: ATA VBOX HARDDISK
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
Model: ATA VBOX HARDDISK
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
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 .
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 .
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.
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?
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).
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