无法安装使用“cryptsetup reencrypt”加密的分区

无法安装使用“cryptsetup reencrypt”加密的分区

我刚刚使用以下命令加密了外部硬盘驱动器的 ext4 分区:

sudo cryptsetup reencrypt --encrypt /dev/sda2 --reduce-device-size 16MiB -N

这已成功完成,如果我尝试再次运行它,它会显示:

Device /dev/sda2 is already LUKS device. Aborting operation.

到目前为止,一切都很好。现在让我们尝试打开 luks 分区:

sudo cryptsetup luksOpen /dev/sda2 mediamapthing

这有效。但是当我运行这个时:

sudo mount /dev/mapper/mediamapthing /media/media

我收到此错误:

mount: /media/media: special device /dev/mapper/mediamapthing does not exist.

我的猜测是第一个命令以某种方式破坏了我的文件系统(可能是--reduce-device-size),但我想知道这是否可以恢复/我只是运行了错误的命令来安装它。

在 dmesg 中我看到的是这样的:

[ 2260.777750] /dev/mapper/mediamapthing: Can't open blockdev

这不是很有帮助。

我的 fstab 中没有与此驱动器相关的任何内容:

UUID=21c04bb1-7cf9-491c-82a2-57222bbf5fb0   /           ext4        rw,relatime 0 1
UUID=34a4e502-bd77-40e3-ace1-c1df54c531c3   /home           ext4        rw,relatime 0 1
UUID=B4A8-67EE          /boot       vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro   0 2

更多信息:

$ sudo systemctl status dev-mapper-mediamapthing.device systemd-cryptsetup@mediamapthing
Unit [email protected] could not be found.
● dev-mapper-mediamapthing.device - /dev/mapper/mediamapthing
    Follows: unit currently follows state of sys-devices-virtual-block-dm\x2d0.device
     Loaded: loaded
     Active: active (plugged) since Tue 2022-11-01 12:21:49 PDT; 4min 46s ago
      Until: Tue 2022-11-01 12:21:49 PDT; 4min 46s ago
     Device: /sys/devices/virtual/block/dm-0

$ sudo dmsetup table
mediamapthing: 0 4334788608 crypt aes-xts-plain64 :64:logon:cryptsetup:1186f7eb-b29a-46b7-bd1d-c69446f53c47-d0 0 8:2 16384

$ sudo cryptsetup status /dev/mapper/mediamapthing
/dev/mapper/mediamapthing is active.
  type:    LUKS2
  cipher:  aes-xts-plain64
  keysize: 512 bits
  key location: keyring
  device:  /dev/sda2
  sector size:  512
  offset:  16384 sectors
  size:    4334788608 sectors
  mode:    read/write

$ sudo cryptsetup luksDump /dev/sda2
LUKS header information
Version:        2
Epoch:          529153
Metadata area:  16384 [bytes]
Keyslots area:  8355840 [bytes]
UUID:           1186f7eb-b29a-46b7-bd1d-c69446f53c47
Label:          (no label)
Subsystem:      (no subsystem)
Flags:          (no flags)

Data segments:
  0: crypt
    offset: 8388608 [bytes]
    length: (whole device)
    cipher: <redacted>
    sector: 512 [bytes]

Keyslots:
  0: luks2
    Key:        512 bits
    Priority:   normal
    Cipher:     aes-xts-plain64
    Cipher key: 512 bits
    PBKDF:      argon2id
    Time cost:  7
    Memory:     1048576
    Threads:    4
    Salt:       <redacted>
    AF stripes: 4000
    AF hash:    sha256
    Area offset:32768 [bytes]
    Area length:258048 [bytes]
    Digest ID:  0
Tokens:
Digests:
  0: pbkdf2
    Hash:       sha256
    Iterations: 142160
    Salt:       <redacted>
    Digest:     <redacted>

$ blkid
/dev/mapper/mediamapthing: LABEL="stuff" UUID="238b30f9-0f23-43b6-9ebe-8389943dd5fb" BLOCK_SIZE="4096" TYPE="ext4"

$ file -sL /dev/mapper/* /dev/dm-*
/dev/mapper/mediamapthing: Linux rev 1.0 ext4 filesystem data, UUID=238b30f9-0f23-43b6-9ebe-8389943dd5fb, volume name "stuff" (errors) (extents) (64bit) (large files) (huge files)
/dev/dm-0:                 Linux rev 1.0 ext4 filesystem data, UUID=238b30f9-0f23-43b6-9ebe-8389943dd5fb, volume name "stuff" (errors) (extents) (64bit) (large files) (huge files)

相关内容