Set up encrypted FS with LUKS

From Wiki
Jump to: navigation, search

First create the device.

cryptsetup luksFormat /dev/sdg1

Now open the device. You will be prompted for the passphrase.

cryptsetup luksOpen /dev/sdg1 name

Create a file system on the device.

mkfs.xfs /dev/mapper/name

Create a key file.

dd if=/dev/urandom of=/etc/security/name.key bs=512 count=4

Add key to device.

cryptsetup luksAddKey /dev/sdg1 /etc/security/name.key 

Add device to /etc/crypttab

# name          /dev/mapper/name 	          /etc/security/name.key