- Lab
- A Cloud Guru
Creating a New Encrypted Volume Using LUKS
In this hands-on lab, we will use Linux Unified Key Setup (LUKS) to encrypt a volume on a Red Hat host. Then we'll go through the process of unmounting and closing the volume and re-opening and re-mounting the volume, which is standard practice for encrypted volumes not mounted at boot. *This course is not approved or sponsored by Red Hat.*
Path Info
Table of Contents
-
Challenge
Create a New Logical Volume
- Run the
vgs
command to view a list of available volume groups. - Next, run
lvcreate -L 100M -n patient_lv luks_vg
to create a new logical volume. - Run the
lvs
command to verify that the new logical volume was created.
- Run the
-
Challenge
Encrypt the Volume with LUKS
- Run the following command:
cryptsetup luksFormat /dev/mapper/luks_vg-patient_lv
- Type
YES
at the prompt. - Enter the passphrase
Pinehead1!
at the next two prompts. - Next, run the command
blkid | grep patient
, and check forTYPE=crypto_LUKS
in the output. - Next, format the volume with the following command:
cryptsetup luksOpen /dev/mapper/luks_vg-patient_lv patient_lv
- Enter the passphrase
Pinehead1!
at the prompt. - Next, run the command
ls /dev/mapper
, and check forpatient_lv
in the output. - Run the following command to overwrite all of the storage on the new volume:
shred -v -n1 /dev/mapper/patient_lv
- Next, format the new volume using ext4 with the following command:
mkfs.ext4 /dev/mapper/patient_lv
- Next, mount the volume to
/data
.
mount /dev/mapper/patient_lv /data
- Run the command
ls /data
, and check forlost+found
in the output. - Check the status of the new encrypted volume.
cryptsetup -v status patient_lv
-
Challenge
Create a Test File on the New Volume
- Run the command
touch test.txt /data
to create the test file.
- Run the command
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.