Home > System Tutorial > LINUX > body text

Methods and steps to implement Linux disk encryption

WBOY
Release: 2024-01-05 08:45:25
forward
778 people have browsed it
1. First we install the partition tool
[root@vipuser200 ~]# yum -y install cryptsetup#yum安装加密工具
Copy after login
2. Next, we add a partition on the virtual machine
[root@vipuser200 ~]# fdisk /dev/sdd#步骤就不详解了

[root@vipuser200 ~]# partprobe /dev/sdd#获取分区表

[root@vipuser200 ~]# cryptsetup luksFormat /dev/sdd1#设置密码Format F必须大写

WARNING!

========

This will overwrite data on /dev/sdd1 irrevocably.

Are you sure? (Type uppercase yes): YES#必须为大写YES

Enter LUKS passphrase: #密码

Verify passphrase:#再次验证密码
Copy after login
3. Mapping partitions is done for security reasons similar to yesterday’s soft connections
[root@vipuser200 ~]# cryptsetup luksOpen /dev/sdd1 my_disk#Open O必须大写

Enter passphrase for /dev/sdd1:#密码
Copy after login
4. View the encrypted disk mapping partition
[root@vipuser200 ~]# ll /dev/mapper/#存放位置

total 0

crw-rw---- 1 root root 10, 58 Jul 27 01:01 control

lrwxrwxrwx 1 root root 7 Jul 27 01:20 my_disk -> ../dm-0

#注:my_disk 指向/dm-0
Copy after login
5. Format mapped partition
[root@vipuser200 ~]# mkfs.ext4 /dev/mapper/my_disk
Copy after login
6. Create a mount point and mount it on the partition
[root@vipuser200 ~]# mkdir mapper_mount#创建挂载点

[root@vipuser200 ~]# mount /dev/mapper/my_disk mapper_mount/#挂载
Copy after login
7. Check the mounting status
[root@vipuser200 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 9.9G 1.4G 8.0G 15% /

tmpfs 479M 0 479M 0% /dev/shm

/dev/sda1 194M 27M 158M 15% /boot

/dev/sr0 3.6G 3.6G 0 100% /mnt

/dev/mapper/my_disk 20G 172M 19G 1% /root/mapper_mount
Copy after login
8. Close the encrypted partition
[root@vipuser200 ~]# umount /root/mapper_mount/#首先卸载

[root@vipuser200 ~]# cryptsetup luksClose /dev/mapper/my_disk

#关闭加密分区 luksClose C大写

[root@vipuser200 ~]# mount /dev/sdd1 mapper_mount/#再次挂载发现失败

mount: unknown filesystem type 'crypto_LUKS

#如果需要使用该磁盘则需要先打开磁盘及luksOpen命令然后载挂载
Copy after login

The above is the detailed content of Methods and steps to implement Linux disk encryption. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!