Disk Encryption User Guide

What is block device encryption?
Block device encryption protects the data on a block device by encrypting it. To access the device's decrypted contents, a user must provide a passphrase or key as authentication. This provides additional security beyond existing OS security mechanisms in that it protects the device's contents even if it has been physically removed from the system.

Encrypting block devices using dm-crypt/LUKS
LUKS (Linux Unified Key Setup) is a specification for block device encryption. It establishes an on-disk format for the data, as well as a passphrase/key management policy.

LUKS uses the kernel device mapper subsystem via the  module. This arrangement provides a low-level mapping that handles encryption and decryption of the device's data. User-level operations, such as creating and accessing encrypted devices, are accomplished through the use of the  utility.

Overview of LUKS

 * What LUKS does:
 * LUKS encrypts entire block devices
 * LUKS is thereby well-suited for protecting the contents of mobile devices such as:
 * Removable storage media
 * Laptop disk drives
 * The underlying contents of the encrypted block device are arbitrary.
 * This makes it useful for encrypting  devices.
 * This can also be useful with certain databases that use specially formatted block devices for data storage.
 * LUKS uses the existing device mapper kernel subsystem.
 * This is the same subsystem used by LVM, so it is well tested.
 * LUKS provides passphrase strengthening.
 * This protects against dictionary attacks.
 * LUKS devices contain multiple key slots.
 * This allows users to add backup keys/passphrases.
 * What LUKS does not do:
 * LUKS is not well-suited for applications requiring many (more than eight) users to have distinct access keys to the same device.
 * LUKS is not well-suited for applications requiring file-level encryption.

How will I access the encrypted devices after installation? (System Startup)
During system startup you will be presented with a passphrase prompt. After the correct passphrase has been provided the system will continue to boot normally. If you used different passphrases for multiple encypted devices you may need to enter more than one passphrase during the startup.

Choosing a Good Passphrase
While dm-crypt/LUKS supports both keys and passphrases, the anaconda installer only supports the use of passphrases for creating and accessing encrypted block devices during installation.

LUKS does provide passphrase strengthening but it is still a good idea to choose a good (meaning "difficult to guess") passphrase. Note the use of the term "passphrase", as opposed to the term "password". This is intentional. Providing a phrase containing multiple words to increase the security of your data is important.

Creating Encrypted Block Devices in Anaconda
You can create encrypted devices during system installation. This allows you to easily configure a system with encrypted partitions.

To enable block device encryption, check the "Encrypt System" checkbox when selecting automatic partitioning or the "Encrypt" checkbox when creating an individual partition, software RAID array, or logical volume. After you finish partitioning, you will be prompted for an encryption passphrase. This passphrase will be required to access the encrypted devices. If you have pre-existing LUKS devices and provided correct passphrases for them earlier in the install process the passphrase entry dialog will also contain a checkbox. Checking this checkbox indicates that you would like the new passphrase to be added to an available slot in each of the pre-existing encrypted block devices.

What Kinds of Block Devices Can Be Encrypted?
Most types of block devices can be encrypted using LUKS. From anaconda you can encrypt partitions, LVM physical volumes, LVM logical volumes, and software RAID arrays.

Filling the Device with Random Data Before Encrypting
Filling a device with random data prior to encrypting improves the strength of the encryption. However, it can take a very long time to fill the device with random data. It is because of those time requirements that anaconda does not offer this option. This step can be performed manually, using a  script. Instructions can be found here.

Using a Key Comprised of Randomly Generated Data to Access Encrypted Devices
In addition to passphrases, LUKS devices can be accessed with a key comprised of randomly generated data. Setting up one or more keys to access the encrypted devices can be done on the installed system or through the use of a  script. Instructions can be found here.

Creating Encrypted Block Devices on the Installed System After Installation
Encrypted block devices can be created and configured after installation.

Create the block devices
Create the block devices you want to encrypt by using,  ,   and.

Optional: Fill the device with random data
Filling (eg: ) with random data before encrypting it greatly increases the strength of the encryption. The downside is that it can take a very long time.


 * The best way, which provides high quality random data but takes a long time (several minutes per gigabyte on most systems)
 * dd if=/dev/urandom of=
 * Fastest way, which provides lower quality random data
 * badblocks -c 10240 -s -w -t random -v

Format the device as a dm-crypt/LUKS encrypted device
cryptsetup luksFormat

After supplying the passphrase twice the device will be formatted for use. To verify, use the following command:

cryptsetup isLuks && echo Success

To see a summary of the encryption information for the device, use the following command:

cryptsetup luksDump

Create a mapping to allow access to the device's decrypted contents
To access the device's decrypted contents, a mapping must be established using the kernel.

It is useful to choose a meaningful name for this mapping. LUKS provides a UUID (Universally Unique Identifier) for each device. This, unlike the device name (eg: ), is guaranteed to remain constant as long as the LUKS header remains intact. To find a LUKS device's UUID, run the following command:

cryptsetup luksUUID

An example of a reliable, informative and unique mapping name would be, where is replaced with the device's LUKS UUID (eg:  ). This naming convention might seem unwieldy but is it not necessary to type it often.

cryptsetup luksOpen

There should now be a device node,, which represents the decrypted device. This block device can be read from and written to like any other unencrypted block device.

To see some information about the mapped device, use the following command:

dmsetup info

Create filesystems on the mapped device, or continue to build complex storage structures using the mapped device
Use the mapped device node as any other block device. To create an  filesystem on the mapped device, use the following command:

mke2fs /dev/mapper/

To mount this filesystem on, use the following command:

mount /dev/mapper/ /mnt/test

Add the mapping information to
In order for the system to set up a mapping for the device, an entry must be present in the  file. If the file doesn't exist, create it and change the owner and group to root and change the mode to. Add a line to the file with the following format:

none

The field should be given in the form "UUID=", where  is the LUKS uuid as given by the command. This ensures the correct device will be identified and used even if the device node (eg: ) changes.

Add an entry to
Add an entry to /etc/fstab. This is only necessary if you want to establish a persistent association between the device and a mountpoint. Use the decrypted device,  in the /etc/fstab file.

In many cases it is desirable to list devices in  by UUID or by a filesystem label. The main purpose of this is to provide a constant identifier in the event that the device name (eg: ) changes. LUKS device names in the form of  are based only on the device's LUKS UUID, and are therefore guaranteed to remain constant. This fact makes them suitable for use in.

Generate a key
This will generate a 256-bit key in the file.

dd if=/dev/urandom of=$HOME/keyfile bs=32 count=1 chmod 600 $HOME/keyfile

Add the key to an available keyslot on the encrypted device
cryptsetup luksAddKey ~/keyfile

Add a new passphrase to an existing device
cryptsetup luksAddKey

After being prompted for any one of the existing passprases for authentication, you will be prompted to enter the new passphrase.

Remove a passphrase or key from a device
cryptsetup luksRemoveKey

You will be prompted for the passphrase you wish to remove and then for any one of the remaining passphrases for authentication.