LVM encryption in CentOS

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.