Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 1 | dm-crypt |
| 2 | ========= |
| 3 | |
| 4 | Device-Mapper's "crypt" target provides transparent encryption of block devices |
| 5 | using the kernel crypto API. |
| 6 | |
Milan Broz | ed04d98 | 2013-10-28 23:21:04 +0100 | [diff] [blame] | 7 | For a more detailed description of supported parameters see: |
Milan Broz | e44f23b | 2015-04-05 18:03:10 +0200 | [diff] [blame] | 8 | https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt |
Milan Broz | ed04d98 | 2013-10-28 23:21:04 +0100 | [diff] [blame] | 9 | |
Milan Broz | 772ae5f | 2011-08-02 12:32:08 +0100 | [diff] [blame] | 10 | Parameters: <cipher> <key> <iv_offset> <device path> \ |
| 11 | <offset> [<#opt_params> <opt_params>] |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 12 | |
| 13 | <cipher> |
| 14 | Encryption cipher and an optional IV generation mode. |
Milan Broz | ed04d98 | 2013-10-28 23:21:04 +0100 | [diff] [blame] | 15 | (In format cipher[:keycount]-chainmode-ivmode[:ivopts]). |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 16 | Examples: |
| 17 | des |
| 18 | aes-cbc-essiv:sha256 |
| 19 | twofish-ecb |
| 20 | |
| 21 | /proc/crypto contains supported crypto modes |
| 22 | |
| 23 | <key> |
| 24 | Key used for encryption. It is encoded as a hexadecimal number. |
Milan Broz | ed04d98 | 2013-10-28 23:21:04 +0100 | [diff] [blame] | 25 | You can only use key sizes that are valid for the selected cipher |
| 26 | in combination with the selected iv mode. |
| 27 | Note that for some iv modes the key string can contain additional |
| 28 | keys (for example IV seed) so the key contains more parts concatenated |
| 29 | into a single string. |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 30 | |
Milan Broz | d1f9642 | 2011-01-13 19:59:54 +0000 | [diff] [blame] | 31 | <keycount> |
| 32 | Multi-key compatibility mode. You can define <keycount> keys and |
| 33 | then sectors are encrypted according to their offsets (sector 0 uses key0; |
| 34 | sector 1 uses key1 etc.). <keycount> must be a power of two. |
| 35 | |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 36 | <iv_offset> |
| 37 | The IV offset is a sector count that is added to the sector number |
| 38 | before creating the IV. |
| 39 | |
| 40 | <device path> |
| 41 | This is the device that is going to be used as backend and contains the |
| 42 | encrypted data. You can specify it as a path like /dev/xxx or a device |
| 43 | number <major>:<minor>. |
| 44 | |
| 45 | <offset> |
| 46 | Starting sector within the device where the encrypted data begins. |
| 47 | |
Milan Broz | 772ae5f | 2011-08-02 12:32:08 +0100 | [diff] [blame] | 48 | <#opt_params> |
| 49 | Number of optional parameters. If there are no optional parameters, |
| 50 | the optional paramaters section can be skipped or #opt_params can be zero. |
| 51 | Otherwise #opt_params is the number of following arguments. |
| 52 | |
| 53 | Example of optional parameters section: |
Mikulas Patocka | 0f5d8e6 | 2015-02-13 08:27:08 -0500 | [diff] [blame] | 54 | 3 allow_discards same_cpu_crypt submit_from_crypt_cpus |
Milan Broz | 772ae5f | 2011-08-02 12:32:08 +0100 | [diff] [blame] | 55 | |
| 56 | allow_discards |
| 57 | Block discard requests (a.k.a. TRIM) are passed through the crypt device. |
| 58 | The default is to ignore discard requests. |
| 59 | |
| 60 | WARNING: Assess the specific security risks carefully before enabling this |
| 61 | option. For example, allowing discards on encrypted devices may lead to |
| 62 | the leak of information about the ciphertext device (filesystem type, |
| 63 | used space etc.) if the discarded blocks can be located easily on the |
| 64 | device later. |
| 65 | |
Mikulas Patocka | f3396c58 | 2015-02-13 08:23:09 -0500 | [diff] [blame] | 66 | same_cpu_crypt |
| 67 | Perform encryption using the same cpu that IO was submitted on. |
| 68 | The default is to use an unbound workqueue so that encryption work |
| 69 | is automatically balanced between available CPUs. |
| 70 | |
Mikulas Patocka | 0f5d8e6 | 2015-02-13 08:27:08 -0500 | [diff] [blame] | 71 | submit_from_crypt_cpus |
| 72 | Disable offloading writes to a separate thread after encryption. |
| 73 | There are some situations where offloading write bios from the |
| 74 | encryption threads to a single thread degrades performance |
| 75 | significantly. The default is to offload write bios to the same |
| 76 | thread because it benefits CFQ to have writes submitted using the |
| 77 | same context. |
| 78 | |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 79 | Example scripts |
| 80 | =============== |
| 81 | LUKS (Linux Unified Key Setup) is now the preferred way to set up disk |
| 82 | encryption with dm-crypt using the 'cryptsetup' utility, see |
Milan Broz | e44f23b | 2015-04-05 18:03:10 +0200 | [diff] [blame] | 83 | https://gitlab.com/cryptsetup/cryptsetup |
Milan Broz | e3dcc5a | 2008-04-24 22:11:03 +0100 | [diff] [blame] | 84 | |
| 85 | [[ |
| 86 | #!/bin/sh |
| 87 | # Create a crypt device using dmsetup |
| 88 | dmsetup create crypt1 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0" |
| 89 | ]] |
| 90 | |
| 91 | [[ |
| 92 | #!/bin/sh |
| 93 | # Create a crypt device using cryptsetup and LUKS header with default cipher |
| 94 | cryptsetup luksFormat $1 |
| 95 | cryptsetup luksOpen $1 crypt1 |
| 96 | ]] |