我有一块 256 GB (232.88 GiB) M.2 SSD,采用 GPT 和一个根分区,这是一个“全驱动器”LUKS 2。该驱动器实际上也有一些未加密的分区 - 带有 cryptsetup、恢复和交换的引导加载程序。该驱动器上安装了 Pop!_OS 20.04。
最近,我尝试使用 KDE Plasma 的 KDE 分区管理器从实时 USB Artix Linux 缩小 LUKS 2 加密根分区(以分配 mote 空间进行交换)。以下是我执行的步骤(注意:所有操作均通过 GUI 在 KDE 分区管理器中执行):
- 我已经解密(“解锁”,使用密码解密)LUKS 2 分区
/dev/sda3
(大小为 224.40 GiB,仅使用了 158.36 GiB); - 我已经在 KDE 分区管理器中打开了“解锁”分区的映射器设备(在我的情况下它位于路径
/dev/data_h3LfB
); root
我已经将 LUKS 容器“内部”尾部(从右侧,最后)分区的体积缩小到 208.38 GiB,应该释放了 16 GiB;- 我已成功保存更改;
- 我尝试再次调整分区大小(因为我需要更多的空间用于交换),但是应用程序开始给我一个错误:
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.
以下是一些日志和调试信息:
# 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
# e2fsck /dev/data_h3LfB/root
e2fsck 1.46.5 (30-Dec-2021)
The filesystem size (according to the superblock) is 58819584 blocks
The physical size of the device is 54624256 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? yes
# lvdisplay
--- Logical volume ---
LV Path /dev/data_h3LfB/root
LV Name root
VG Name data_h3LfB
LV UUID IieMpP-a4AZ-5NCr-jp7O-YxRX-iIIp-Rk9UJU
LV Write Access read/write
LV Creation host, time pop-os, 2020-11-24 00:54:18 +0500
LV Status available
# open 0
LV Size <208.38 GiB
Current LE 53344
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
# vgdisplay
--- Volume group ---
VG Name data_h3LfB
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <224.38 GiB
PE Size 4.00 MiB
Total PE 57441
Alloc PE / Size 53344 / <208.38 GiB
Free PE / Size 4097 / 16.00 GiB
VG UUID yj7JnE-u3OE-4hGA-v7cv-14dt-U9Xh-yGtRww
LUKS 标头看起来不错。
# fdisk /dev/data_h3LfB/root
Welcome to fdisk (util-linux 2.38).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb8237d87.
Command (m for help): p
Disk /dev/data_h3LfB/root: 208.38 GiB, 223740952576 bytes, 436994048 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb8237d87
Command (m for help): F
Unpartitioned space /dev/data_h3LfB/root: 208.37 GiB, 223739904000 bytes, 436992000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Start End Sectors Size
2048 436994047 436992000 208.4G
Fdisk 不将该分区识别为分区,也不将可用空间识别为可用空间。
数据丢失了还是仍然可以恢复?如何恢复?LUKS 2 分区的分区表存储在哪里?是否可以手动“恢复”它?
答案1
lvextend --extents +100%FREE /dev/mapper/data_h3LfB-root
帮我解决了所有问题。
更多的这里。