无法使用 cryptsetup 挂载分区

无法使用 cryptsetup 挂载分区

我有一个备用驱动器。我尝试将其格式化并加密。但即使该过程似乎成功并且我可以打开加密,我也无法安装新映射的设备。以下是我的命令的输出:

# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
16 heads, 63 sectors/track, 2907021 cylinders, total 2930277168 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
Disk identifier: 0x60e924ef

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  2930277167  1465137560   83  Linux

Command (m for help): d
Selected partition 1

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-2930277167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2930277167, default 2930277167): 
Using default value 2930277167

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
91578368 inodes, 366284390 blocks
18314219 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
11179 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

# cryptsetup -v luksFormat /dev/sdb1

WARNING!
========
This will overwrite data on /dev/sdb1 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter passphrase: 
Verify passphrase: 
Command successful.

# cryptsetup luksOpen /dev/sdb1 mycrypt
Enter passphrase for /dev/sdb1:

# ls -l /dev/mapper/mycrypt 
lrwxrwxrwx 1 root root 7 Apr 21 20:41 /dev/mapper/mycrypt -> ../dm-0

# mount -t ext4 /dev/mapper/mycrypt /mount/mycrypt/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/mycrypt,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

答案1

我错过了一个重要的步骤......你必须格式化新的加密设备。

mkfs.ext4 /dev/mapper/mycrypt
mount /dev/mapper/mycrypt /mount/mycrypt/

相关内容