How to encrypt partition in redhat enterprise linux using LUKS

Posted: 11 Feb 2016 in LINUX
Tags: , , , , , , ,

In this tutorial we will learn how to create encrypted partition in linux and at the same time we will also learn how to create mapping of encrypted partition in linux.One who want to secure his data by encrypting his hard drive can be done very easily after reading this article.

This article will show you step wise methods to encrypt a partition in redhat enterprise linux using cryptsetup command.We are using LUKS which is standard for linux hard disk encryption in this tutorial.

LUKS stands for  Linux Unified Key Setup.

LUKS stores it information in partition header and enable the user to transport his/her data seamlessly and is free.

Using LUKS we will learn how to unmount to secure our data.

Using LUKS we will also learn how to mount or remount encrypted partition in linux.

We will also learn how to change LUKS password or passphrase for encrypted partition.


Step-1: First create a partition using fdisk.

Here i have created a partition named /dev/sda6 and i am going to encrypt this partition for my data security.Dont format the created partition here now.just create partition and run partprobe command to save the changes made in partition table.Thats all.


Step-2:Now i am going to encrypt /dev/sda6 partition

#cryptsetup  -y  -v  luksFormat   /dev/sda6


Step-3:Now the passphrase provided in above command is not recoverable so creat a mapping using below command.

#cryptsetup  luksOpen    /dev/sda6    satish

You can see the mapping name now as /dev/mapper/satish after successful verification of the supplied key in the above command.

#ls    -l     /dev/mapper/satish


Step-4:If you want to see the status of mapping use below command.

#cryptsetup -v    status   satish

Step-5: Format LUKS partition and then mount it.

#mkfs.ext3     /dev/mapper/satish
#mkdir  /data
#mount   /dev/mapper/satish      /data
#df -H
#cryptsetup   -v    status     /dev/mapper/satish

Step-5:Now if you want to secure your data you have to unmount it using below command.

#umount /data
#df -H
#cryptsetup   luksClose  /dev/mapper/satish

Step-6:Now if you want to read your data you need to mount it.

So to mount or remount your encrypted partition you need to type below command.

#cryptsetup   luksOpen  /dev/sda6   data
#mount    /dev/mapper/satish    /data
#df -H

Step-7:If you want to change the password of your encrypted partition you can do it by using below command.

#cryptsetup    luksDump    /dev/sda6
#cryptsetup    luksAddKey  /dev/sda6

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.