我已成功从 32Mb USB 闪存驱动器创建 LUKS 驱动器。但是,当我向其中写入 ext4 文件系统时,我无法安装结果,甚至无法运行fsck
等dumpe2fs
。
该驱动器显示lsblk
为
sda 8:0 1 31M 0 disk
└─luks 253:0 0 15M 0 crypt
然后我用 编写文件系统sudo mkfs.ext4 -v /dev/mapper/luks
,它会产生
mke2fs 1.45.5 (07-Jan-2020)
fs_types for mke2fs.conf resolution: 'ext4', 'small'
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3840 inodes, 3840 blocks
192 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4194304
1 block group
32768 blocks per group, 32768 fragments per group
3840 inodes per group
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
各种命令的输出
$ sudo cryptsetup luksDump /dev/sda
LUKS header information
Version: 2
Epoch: 3
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 1f30e940-4144-4980-a32a-4f1b78a46fc5
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: 187471
Threads: 4
Salt: 5c c4 28 e0 bc f6 7f df b2 1c 77 b6 fa f3 f1 bc
48 66 fc 56 e3 5c e5 13 cc af 1d 52 ec df fc 93
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 18853
Salt: 62 8a b7 2c 4d 74 d3 6b 46 c2 9b 34 e2 d6 5c 3d
06 12 ee a7 5b b0 81 1f d0 99 19 b6 4f de 5c 77
Digest: c2 71 c1 d5 de 16 d9 cc 8c 15 f2 34 21 42 3a a3
24 d1 82 26 cd ab f9 98 0c 0a 68 7a 35 e2 3d a9
^Subsystem: (no subsystem)
线路令人担忧
$ sudo mount -v /dev/mapper/luks /media/luks
mount: /media/luks: wrong fs type, bad option, bad superblock on /dev/mapper/luks, missing codepage or helper program, or other error.
$ sudo fsck /dev/mapper/luks
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/luks
...
^fsck.ext2
向我表明它无法告诉文件系统
$ sudo dumpe2fs /dev/mapper/luks
dumpe2fs 1.45.5 (07-Jan-2020)
dumpe2fs: Bad magic number in super-block while trying to open /dev/mapper/luks
Couldn't find valid filesystem superblock.
所有这些都表明文件系统尚未正确创建,但是据我所知,即使是区区 15Mb 的空间也应该足够了,我不确定还有什么问题
答案1
听起来像是硬件问题。您应该badblocks
在设备上以写入模式运行。
另一种选择是
- 创建一个小图像文件(几百 MiB)
- 在上面放一个循环装置
- 在其中创建文件系统
- 将图像文件复制到设备(的第一部分)
- 将图像文件与设备的相应部分进行比较
dd if=/dev/zero of=/path/to/imagefile bs=1M count=100
losetup /dev/loop0 /path/to/imagefile
mkfs.ext4 /dev/loop0
blockdev --getsz /dev/loop0
204800
dd if=imagefile of=/dev/mapper/luks
sha1sum imagefile
aaafc117548aaebef3dbb5f4a609022e386192b6 imagefile
dd if=/dev/mapper/luks count=204800 | sha1sum
204800+0 Datensätze ein
204800+0 Datensätze aus
aaafc117548aaebef3dbb5f4a609022e386192b6 -