linux

Encrypting and formatting disks on Linux

1 min read

Steps to encrypt disks on Linux (tested here on Xubuntu 16.04)

Wipe the disk

bash
    dd if=/dev/zero of=/dev/<disk>

Encrypt the disk

bash
    cryptsetup -y -v luksFormat /dev/<disk>

Decrypt the disk to access it

bash
    cryptsetup luksOpen /dev/<disk> <name>

the name can be anything you like. Format the disk

bash
    mkfs.ext4 /dev/mapper/<name>

create a mount point

bash
    mkdir /media/<mount point>

mount the disk

bash
    mount -t ext4 /dev/mapper/<name> /media/<mount point>

To unmount and encrypt it again

bash
    umount /media/<mount point>
    cryptsetup luksClose <name>

#encryption#linux