Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use cryptsetup to encrypt disk under Linux

Shulou Source: shulou.com Published: 2022-06-01 20:43:17 09月21日 Update

This article mainly introduces how to use cryptsetup to encrypt the disk under Linux. It is very detailed and has a certain reference value. Friends who are interested must read it!

Cryptsetup is a partition encryption tool under linux. Cryptsetup is partition-level encryption, which works at a lower level than the file system level. It is on encrypted block devices, and then create a file system and mount it for use.

1. First, we install the partition tool [root@vipuser200 ~] # yum-y install cryptsetup#yum install encryption tool 2. Secondly, we add a partition [root@vipuser200 ~] # fdisk / dev/sdd# on the virtual machine without detailed explanation of [root@vipuser200 ~] # partprobe / dev/sdd# get partition table [root@vipuser200 ~] # cryptsetup luksFormat / dev/sdd1# set password Format F must uppercase WARNINGRAM encrypt this will overwrite data on / dev/sdd1 irrevocably.Are you sure? (Type uppercase yes): YES# must verify password again for uppercase YESEnter LUKS passphrase:# password Verify passphrase:#, map partition to do so for security similar to yesterday's soft connection [root@vipuser200 ~] # cryptsetup luksOpen / dev/sdd1 my_disk#Open O must uppercase Enter passphrase for / dev/sdd1:# password 4, view encrypted disk map partition [root@vipuser200 ~] # ll / dev/mapper/# storage location total 0CrwMuk dev/mapper/#-1 root root 10 58 Jul 27 01:01 controllrwxrwxrwx 1 root root 7 Jul 27 01:20 my_disk->.. / dm-0# Note: my_disk points to / dm-05, formatted mapping partition [root@vipuser200 ~] # mkfs.ext4 / dev/mapper/my_disk6, create mount point and mount it in partition [root@vipuser200 ~] # mkdir mapper_mount# create mount point [root@vipuser200 ~] # mount/ dev/mapper/my_disk mapper_mount/# mount 7, Check the mount status [root@vipuser200 ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/sda2 9.9G 1.4G 8.0G 15% / tmpfs 479M 0479m 0% / dev/shm/dev/sda1 194M 27M 158m 15% / boot/dev/sr0 3.6G 3.6G 0100% / mnt/dev/mapper/my_disk 20G 172m 19G 1% / root/mapper_mount8, Close the encrypted partition [root@vipuser200 ~] # umount / root/mapper_mount/# first uninstall [root@vipuser200 ~] # cryptsetup luksClose / dev/mapper/my_disk# close the encrypted partition luksClose C uppercase [root@vipuser200 ~] # mount/ dev/sdd1 mapper_mount/# again mount failed mount: unknown filesystem type 'crypto_LUKS# if you need to use the disk, you need to open the disk and luksOpen command before mounting

The above is all the contents of the article "how to encrypt the disk with cryptsetup under Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Encryption disk uppercase password tool location content again file article system security value interest command boy buddy bottom layer point to is in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Shulou Technology MySQL Xiaomi