You are not logged in.

#1 2023-12-21 13:35:10

Syxal
Member
From: Switzerland
Registered: 2023-06-11
Posts: 14

[Solved] Ykfde encrypted won't open after partition resize

Hiya folks,

I have an Arch installation with the root partition encrypted using yubikey-full-disk-encryption

I extended the partition size, but failed at enlarging the logical volume (skill issue + computer unpowered due to cat unplugging the power supply ;-;) and it will no longer open anymore. I tried reverting the changes and putting the original size of 250 gibybytes back (I calculated it to make sure it's a multiple of 4096 bytes), but it doesn't work. I'm not exactly sure what to do.

Here is the relevant part of the output of

 fdisk -l /dev/sda 
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: TOSHIBA DT01ACA1
Units: sectors of 1* 512=512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes 1/0 size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier:
9C503D55-85EE-4997-833B-EA9FCF9D0978
Device;Start;End;Sector;Size;Type
/dev/sda2
1050624 524288000 523237377 249.56 Linux root (x86-64)

And this is the output of

 ykfde-open -d /dev/sda2 -n root 
ykfde-open -d /dev/sda2 -n root
INFO: Setting device to '/dev/sda2'.
INFO: Setting name to 'root'.
WARNING: This script will try to open the 'root' LUKS encrypted volume on drive '/dev/sda2'. If this is not what you intended, please abort.
Remember to touch the device if necessary.
> Decrypting with cryptsetup'.
[ 3042.734904] device-mapper: table: 254:0: crypt: Device size is not multiple of sector_size feature (-E INVAL)
[ 3042.738347] device-mapper: ioctl: error adding target to table
device-mapper: reload ioctl on root (254:0) failed: Invalid argument
ykfde-open -d /dev/sda2 -n root 6.51s user 0.15s system 184% cpu 3.601 total

The challenge-resonse is most definitely working, but then

 /dev/mapper/root 

does not appear in

 lsblk 

The most important error I'm picking up here is about the size not being a multiple of sector-size, and I have absolutely no idea how to fix it

I'm not sure what other informations I should be providing, if any is missing please ask. I'm probably being stupid and missing something obvious

Any clue?

Last edited by Syxal (2023-12-21 15:37:31)

Offline

#2 2023-12-21 14:29:56

frostschutz
Member
Registered: 2013-11-15
Posts: 1,644

Re: [Solved] Ykfde encrypted won't open after partition resize

the partition size (end) is not 4K aligned. this is a problem for LUKS if LUKS is set to use 4K sectors. it will reject devices that are not multiple of 4096 bytes large. fix your partitioning and you should be good to go.

in your example fdisk seems to show 523237377 sectors as the size; that's 1 sector too many or 7 sectors too little.

note the size has to cover your filesystem area plus the luks header itself; if in doubt, if you don't remember the exact size it should be, make it a bit larger.

Last edited by frostschutz (2023-12-21 15:28:59)

Offline

#3 2023-12-21 15:37:15

Syxal
Member
From: Switzerland
Registered: 2023-06-11
Posts: 14

Re: [Solved] Ykfde encrypted won't open after partition resize

Took me a while to actually understand,
I tried a few different sizes and then I remembered that 0 is not actually 0, so the partition should be 524287999 kilobytes instead of 524288000

Thank you a lot! You saved me so many braincells

Last edited by Syxal (2023-12-21 15:49:19)

Offline

Board footer

Powered by FluxBB