DEV Community

Dbaport
Dbaport

Posted on • Originally published at dbaport.com

How to Encrypt a Drive on Ubuntu 18.04

Enable disk encryption after installation

Here I have two disk drive .

SSD as / (root partition)
HDD as /home (home partition)
Installing Cryptsetup:-

$ sudo apt-get install cryptsetup

$ sudo apt-get install lvm2

Copy /home to another location

sudo -i

sudo mkdir /data –> make directory for copy data

sudo cp -avi sumantk /data –> Copy the home

sudo vi /etc/passwd –> change the home path for unmount /home

Unmount the drive

umount /dev/sda1

Format & change to lvm type

sudo mkfs.ext4 /dev/sda1

Format & change to lvm type

pvcreate /dev/sda4

vgcreate vg_home /dev/sda4

lvcreate -n lv_home -l 100%FREE vg_home

cryptsetup luksFormat /dev/mapper/vg_home-lv_home

cryptsetup luksOpen /dev/mapper/vg_home-lv_home mycrypt

mkfs -t ext4 /dev/mapper/mycrypt

vim /etc/crypttab

mycrypt /dev/mapper/vg_home-lv_home

Make a entry in fstab file

vi /etc/fstab

/dev/mapper/mycrypt /home ext4 defaults 0 2

/dev/mapper/vg_home-lv_home /home ext4 defaults 0 2

Top comments (0)