I have a 256 GB (232.88 GiB) M.2 SSD with GPT and a root partition which is a “full-drive” LUKS 2. The drive actually has some unencrypted partitions too – bootloader w/ cryptsetup, recovery & swap. This drive has Pop!_OS 20.04 installed on it.
Recenly I tried to shrink the LUKS 2 encrypted root partition (to allocate mote space to swap) from a live-USB Artix Linux w/ KDE Plasma’s KDE Partition Manager. Here’s the steps I’ve done:
- I’ve unencrypted the LUKS 2 partition at
/dev/sda3
(which is 224.40 GiB in size, and it had only 158.36 GiB used); - I’ve opened the partition’s mapper device in KDE Partition Manager (in my case it was at path
/dev/data_h3LfB
); - I’ve shrinked the volume of the
root
partition “inside” the LUKS container at the tail of it
(from the right, at the end) to the 208.38 GiB, supposedly freeing 16 GiB; - I’ve saved the changs successfully;
- I’ve tried to resize the partition again (because I needed some more space for swap), but the app started to give me an error:
Job: Check file system on partition ‘/dev/data_h3LfB/root’
Command: e2fsck -f -y -v /dev/data_h3LfB/root
Check file system on partition ‘/dev/data_h3LfB/root’: Error
Checking partition ‘/dev/data_h3LfB/root’ before resize/move failed.
Here are some logs and debug info:
# cryptsetup luksDump /dev/sda3
LUKS header information
Version: 2
Epoch: 3
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: d0d243ca-cced-4759-acc1-4fdb807726d6
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)
Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]
Keyslots:
0: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 1048576
Threads: 4
Salt: 70 9c 8e 05 5d 36 b2 df cb 25 05 2b d9 98 a9 91
dc 0e 2a 39 2f c0 b0 89 50 a4 e4 8c ed 53 d8 ff
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 107084
Salt: 66 e8 02 be 6b f0 b4 b3 7c 51 43 16 95 0d f0 11
41 c2 d2 4b c9 72 f4 95 c6 d7 e9 4f 18 aa 8a c7
Digest: b7 45 38 83 7b 94 66 5e 62 a5 c9 46 71 a2 25 4d
dc a5 05 6d 23 98 6f fc 4f 5b ae 32 89 ec 5d 32
hexdump -C -n 16416 /dev/sda3
00000000 4c 55 4b 53 ba be 00 02 00 00 00 00 00 00 40 00 |LUKS..........@.|
00000010 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000040 00 00 00 00 00 00 00 00 73 68 61 32 35 36 00 00 |........sha256..|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 00 00 cd 12 ab c1 70 ae f1 f0 |............p...|
00000070 ea a9 85 7b dc 3f f8 33 3e 89 b6 38 a0 06 f1 19 |...{.?.3>..8....|
00000080 cc 93 ba 84 e6 a5 55 72 10 6a cc 8d 16 f7 59 10 |......Ur.j....Y.|
00000090 b8 cd 5f 7e 65 75 57 9a 69 b2 87 aa 94 75 7e 98 |.._~euW.i....u~.|
000000a0 a1 2a f8 60 1f 3c 04 17 64 30 64 32 34 33 63 61 |.*.`.<..d0d243ca|
000000b0 2d 63 63 65 64 2d 34 37 35 39 2d 61 63 63 31 2d |-cced-4759-acc1-|
000000c0 34 66 64 62 38 30 37 37 32 36 64 36 00 00 00 00 |4fdb807726d6....|
000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001c0 49 8c be 50 d4 2d 5b e4 f1 b8 44 6d 11 be 4f 80 |I..P.-[...Dm..O.|
000001d0 a8 85 1e a0 d5 e3 99 8e 57 a2 78 59 a3 b4 29 76 |........W.xY..)v|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00001000 7b 22 6b 65 79 73 6c 6f 74 73 22 3a 7b 22 30 22 |{"keyslots":{"0"|
00001010 3a 7b 22 74 79 70 65 22 3a 22 6c 75 6b 73 32 22 |:{"type":"luks2"|
00001020 2c 22 6b 65 79 5f 73 69 7a 65 22 3a 36 34 2c 22 |,"key_size":64,"|
00001030 61 66 22 3a 7b 22 74 79 70 65 22 3a 22 6c 75 6b |af":{"type":"luk|
00001040 73 31 22 2c 22 73 74 72 69 70 65 73 22 3a 34 30 |s1","stripes":40|
00001050 30 30 2c 22 68 61 73 68 22 3a 22 73 68 61 32 35 |00,"hash":"sha25|
00001060 36 22 7d 2c 22 61 72 65 61 22 3a 7b 22 74 79 70 |6"},"area":{"typ|
00001070 65 22 3a 22 72 61 77 22 2c 22 6f 66 66 73 65 74 |e":"raw","offset|
00001080 22 3a 22 33 32 37 36 38 22 2c 22 73 69 7a 65 22 |":"32768","size"|
00001090 3a 22 32 35 38 30 34 38 22 2c 22 65 6e 63 72 79 |:"258048","encry|
000010a0 70 74 69 6f 6e 22 3a 22 61 65 73 2d 78 74 73 2d |ption":"aes-xts-|
000010b0 70 6c 61 69 6e 36 34 22 2c 22 6b 65 79 5f 73 69 |plain64","key_si|
000010c0 7a 65 22 3a 36 34 7d 2c 22 6b 64 66 22 3a 7b 22 |ze":64},"kdf":{"|
000010d0 74 79 70 65 22 3a 22 61 72 67 6f 6e 32 69 22 2c |type":"argon2i",|
000010e0 22 74 69 6d 65 22 3a 34 2c 22 6d 65 6d 6f 72 79 |"time":4,"memory|
000010f0 22 3a 31 30 34 38 35 37 36 2c 22 63 70 75 73 22 |":1048576,"cpus"|
00001100 3a 34 2c 22 73 61 6c 74 22 3a 22 63 4a 79 4f 42 |:4,"salt":"cJyOB|
00001110 56 30 32 73 74 2f 4c 4a 51 55 72 32 5a 69 70 6b |V02st/LJQUr2Zipk|
00001120 64 77 4f 4b 6a 6b 76 77 4c 43 4a 55 4b 54 6b 6a |dwOKjkvwLCJUKTkj|
00001130 4f 31 54 32 50 38 3d 22 7d 7d 7d 2c 22 74 6f 6b |O1T2P8="}}},"tok|
00001140 65 6e 73 22 3a 7b 7d 2c 22 73 65 67 6d 65 6e 74 |ens":{},"segment|
00001150 73 22 3a 7b 22 30 22 3a 7b 22 74 79 70 65 22 3a |s":{"0":{"type":|
00001160 22 63 72 79 70 74 22 2c 22 6f 66 66 73 65 74 22 |"crypt","offset"|
00001170 3a 22 31 36 37 37 37 32 31 36 22 2c 22 73 69 7a |:"16777216","siz|
00001180 65 22 3a 22 64 79 6e 61 6d 69 63 22 2c 22 69 76 |e":"dynamic","iv|
00001190 5f 74 77 65 61 6b 22 3a 22 30 22 2c 22 65 6e 63 |_tweak":"0","enc|
000011a0 72 79 70 74 69 6f 6e 22 3a 22 61 65 73 2d 78 74 |ryption":"aes-xt|
000011b0 73 2d 70 6c 61 69 6e 36 34 22 2c 22 73 65 63 74 |s-plain64","sect|
000011c0 6f 72 5f 73 69 7a 65 22 3a 35 31 32 7d 7d 2c 22 |or_size":512}},"|
000011d0 64 69 67 65 73 74 73 22 3a 7b 22 30 22 3a 7b 22 |digests":{"0":{"|
000011e0 74 79 70 65 22 3a 22 70 62 6b 64 66 32 22 2c 22 |type":"pbkdf2","|
000011f0 6b 65 79 73 6c 6f 74 73 22 3a 5b 22 30 22 5d 2c |keyslots":["0"],|
00001200 22 73 65 67 6d 65 6e 74 73 22 3a 5b 22 30 22 5d |"segments":["0"]|
00001210 2c 22 68 61 73 68 22 3a 22 73 68 61 32 35 36 22 |,"hash":"sha256"|
00001220 2c 22 69 74 65 72 61 74 69 6f 6e 73 22 3a 31 30 |,"iterations":10|
00001230 37 30 38 34 2c 22 73 61 6c 74 22 3a 22 5a 75 67 |7084,"salt":"Zug|
00001240 43 76 6d 76 77 74 4c 4e 38 55 55 4d 57 6c 51 33 |CvmvwtLN8UUMWlQ3|
00001250 77 45 55 48 43 30 6b 76 4a 63 76 53 56 78 74 66 |wEUHC0kvJcvSVxtf|
00001260 70 54 78 69 71 69 73 63 3d 22 2c 22 64 69 67 65 |pTxiqisc=","dige|
00001270 73 74 22 3a 22 74 30 55 34 67 33 75 55 5a 6c 35 |st":"t0U4g3uUZl5|
00001280 69 70 63 6c 47 63 61 49 6c 54 64 79 6c 42 57 30 |ipclGcaIlTdylBW0|
00001290 6a 6d 47 2f 38 54 31 75 75 4d 6f 6e 73 58 54 49 |jmG/8T1uuMonsXTI|
000012a0 3d 22 7d 7d 2c 22 63 6f 6e 66 69 67 22 3a 7b 22 |="}},"config":{"|
000012b0 6a 73 6f 6e 5f 73 69 7a 65 22 3a 22 31 32 32 38 |json_size":"1228|
000012c0 38 22 2c 22 6b 65 79 73 6c 6f 74 73 5f 73 69 7a |8","keyslots_siz|
000012d0 65 22 3a 22 31 36 37 34 34 34 34 38 22 7d 7d 00 |e":"16744448"}}.|
000012e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00004000 53 4b 55 4c ba be 00 02 00 00 00 00 00 00 40 00 |SKUL..........@.|
00004010 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 |................|
00004020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
dmesg
[ 6703.195671] EXT4-fs (dm-1): bad geometry: block count 58819584 exceeds size of device (54624256 blocks)
# gdisk
GPT fdisk (gdisk) version 1.0.9
Type device filename, or press <Enter> to exit: /dev/data_h3LfB/root
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries in memory.
Command (? for help): p
Disk /dev/data_h3LfB/root: 436994048 sectors, 208.4 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 27F0C8A2-A959-4875-BC02-5E7234CBB5C3
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 436994014
Partitions will be aligned on 2048-sector boundaries
Total free space is 436993981 sectors (208.4 GiB)
Number Start (sector) End (sector) Size Code Name
Is data lost or still recoverable? How do I restore it?