Encrypt your data using LUKS (Linux)

Encrypt your data using LUKS (Linux)

Hello guys, In this article I will tell you how to your partitions in 6.0. Luks(“ unified key setup”) is the standard format for device encryption.This kind of encryption makes your partitions password protected before the file system in it can be mounted.

First we create a partition using fdisk. If you do not know how to create a partition using fdisk,you can explore the man file for fdisk where you will the procedure to create partitions.After you have created the partition,run the following commands in order.

[email protected]# cryptsetup luksFormat /dev/sdaX

here X is the partition number.

This will ask you to enter a password. After this run

bash script for all files which size is higher than given size in parameter and archive [email protected]# cryptsetup luksOpen /dev/sdaX name

here name is name of the device and can be anything,for eg:

cryptsetup luksOpen /dev/sda5 secret

This will ask for a password,enter the same password you created with luksFormat.

Now format the partition as

[email protected]# mkfs.ext4 /dev/mapper/secret

create a directory to mount the file system

[email protected]# mkdir /test
[email protected]# mount /dev/mapper/secret       /test

For permanent mounting,edit /etc/fstab as follows

/dev/mapper/secret      /test      ext4       defaults               1 2

If you want that password should be asked everytime the machine boots then create a file /etc/crypttab and make following entries

secret   /dev/sdaX

This will ask for password every time your machine boots.

When finished working you can again lock the partition by

[email protected]# umount /dev/mapper/secret
>[email protected]# cryptsetup luksClose secret

Thus we see there are three stages while encrypting a partition

1) Encrypting a partition with a password.

2) Decrypting a partition and mounting the file system.

3) Again encrypting the partition

About Sachin Gupta

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009. rocks!

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *