Cryptsetup is a partition encryption tool in linux. It is a partition-level encryption tool that works at a lower level than the file system level. It creates a file system on an encrypted block device, last mount and use.
1: create a common logical volume
[Root @ orcl ~] # Lvcreate-n data-L 100 M VolGroup00
Rounding up size to full physical extent 128.00 MB
Logical volume "data" created
2: Use the cryptsetup command to set the logical volume as an encrypted block device.
[Root @ orcl ~] # Cryptsetup create en_data/dev/VolGroup00/data
Enter passphrase:
3: Use the command cryptsetup to check the status
[Root @ orcl ~] # Cryptsetup status en_data
/Dev/mapper/en_data is active:
Cipher: aes-cbc-plain
Keysize: 256 bits
Device:/dev/mapper/VolGroup00-data
Offset: 0 sectors
Size: 262144 sectors
Mode: read/write
4: Format encrypted Block devices/dev/mapper/en_data, mount and write data.
[Root @ orcl ~] # Mke2fs-j/dev/mapper/en_data
[Root @ orcl ~] # Tune2fs-c 0-I 0/dev/mapper/en_data
[Root @ orcl ~] # Mount/dev/mapper/en_data/mnt
[Root @ orcl ~] # Cp/etc/passwd/mnt/
5. unmount the block device/dev/mapper/en_data and delete the mapped encrypted block device.
[Root @ orcl ~] # Umount/mnt
[Root @ orcl ~] # Cryptsetup remove en_data
6: re-map the encrypted block device and enter the wrong password. An error will be reported when mounting the device. The ing name may be different from the previous one.
[Root @ orcl ~] # Cryptsetup create en_data1/dev/VolGroup00/data
Enter passphrase:
[Root @ orcl ~] # Mount/dev/mapper/en_data1/mnt
Mount: you must specify the filesystem type
[Root @ orcl ~] # Cryptsetup remove en_data1
7. remap the encrypted block device, enter the correct password, and read the file. The ing name may be different from the previous one.
[Root @ orcl ~] # Cryptsetup create en_data1/dev/VolGroup00/data
Enter passphrase:
[Root @ orcl ~] # Mount/dev/mapper/en_data1/mnt
[Root @ orcl ~] # Ls/mnt
Lost + found passwd
[Root @ orcl ~] # Tail-3/mnt/passwd
Mysql: x: 27: 27:/dev/null:/sbin/nologin
Vmail: x: 1001: 1000:/home/vmail:/bin/bash
Postfix: x: 1000: 1000:/home/postfix:/bin/bash