从 loop-aes 升级到 cryptsetup

从 loop-aes 升级到 cryptsetup

曾几何时,我有一个加密的外部磁盘,我会这样挂载它:

# losetup -e AES128 /dev/loop1 /dev/sdb1
# fsck /dev/loop1
# mount /dev/loop1 /mnt/wd
# ls /wd

有人说,现代的做法是:

# apt-get install cryptsetup
# cryptsetup create -c aes -s 128 wd /dev/sdb1
# fsck /dev/mapper/wd
# mount /dev/mapper/wd /mnt/wd

但这不起作用。有人能帮忙吗?

我怀疑它就像 AES128 一样简单,与 -c aes -s 128 不完全相同。


确切地说,我使用的是 Ubuntu 12.04,旧方法仍然有效,但已被弃用,不再适用于 Debian 或较新的 Ubuntu。新方法似乎没问题,但 fsck 失败:

fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/wd

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device&gt;

如果我说

#cryptsetup status wd

然后我得到:

/dev/mapper/wd is active.
  type:    PLAIN
  cipher:  aes-cbc-plain
  keysize: 128 bits
  device:  /dev/sdb1
  offset:  0 sectors
  size:    3907024002 sectors
  mode:    read/write

我怀疑这很简单,因为 AES128 与 aes-cbc-plain / 128 不一样,但我很难找出它应该是什么。

答案1

对于遇到同样问题的用户,请执行以下操作:

cryptsetup open _path_to_file_or_device_  SOME_NAME  --type plain -c aes -s 128 -h sha256 

mount /dev/mapper/SOME_NAME /media/mount_point/

例子:

cryptsetup open /dev/sdb1 my_enc_disk --type plain -c aes -s 128 -h sha256

mount /dev/mapper/my_enc_disk /media/my_enc_disk

相关内容