]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - Documentation/device-mapper/dm-crypt.txt
Merge branch 'stable/for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-artful-kernel.git] / Documentation / device-mapper / dm-crypt.txt
CommitLineData
e3dcc5a3
MB
1dm-crypt
2=========
3
4Device-Mapper's "crypt" target provides transparent encryption of block devices
5using the kernel crypto API.
6
ed04d981 7For a more detailed description of supported parameters see:
e44f23b3 8https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt
ed04d981 9
772ae5f5
MB
10Parameters: <cipher> <key> <iv_offset> <device path> \
11 <offset> [<#opt_params> <opt_params>]
e3dcc5a3
MB
12
13<cipher>
14 Encryption cipher and an optional IV generation mode.
ed04d981 15 (In format cipher[:keycount]-chainmode-ivmode[:ivopts]).
e3dcc5a3
MB
16 Examples:
17 des
18 aes-cbc-essiv:sha256
19 twofish-ecb
20
21 /proc/crypto contains supported crypto modes
22
23<key>
c538f6ec
OK
24 Key used for encryption. It is encoded either as a hexadecimal number
25 or it can be passed as <key_string> prefixed with single colon
26 character (':') for keys residing in kernel keyring service.
ed04d981
MB
27 You can only use key sizes that are valid for the selected cipher
28 in combination with the selected iv mode.
29 Note that for some iv modes the key string can contain additional
30 keys (for example IV seed) so the key contains more parts concatenated
31 into a single string.
e3dcc5a3 32
c538f6ec
OK
33<key_string>
34 The kernel keyring key is identified by string in following format:
35 <key_size>:<key_type>:<key_description>.
36
37<key_size>
38 The encryption key size in bytes. The kernel key payload size must match
39 the value passed in <key_size>.
40
41<key_type>
42 Either 'logon' or 'user' kernel key type.
43
44<key_description>
45 The kernel keyring key description crypt target should look for
46 when loading key of <key_type>.
47
d1f96423
MB
48<keycount>
49 Multi-key compatibility mode. You can define <keycount> keys and
50 then sectors are encrypted according to their offsets (sector 0 uses key0;
51 sector 1 uses key1 etc.). <keycount> must be a power of two.
52
e3dcc5a3
MB
53<iv_offset>
54 The IV offset is a sector count that is added to the sector number
55 before creating the IV.
56
57<device path>
58 This is the device that is going to be used as backend and contains the
59 encrypted data. You can specify it as a path like /dev/xxx or a device
60 number <major>:<minor>.
61
62<offset>
63 Starting sector within the device where the encrypted data begins.
64
772ae5f5
MB
65<#opt_params>
66 Number of optional parameters. If there are no optional parameters,
67 the optional paramaters section can be skipped or #opt_params can be zero.
68 Otherwise #opt_params is the number of following arguments.
69
70 Example of optional parameters section:
0f5d8e6e 71 3 allow_discards same_cpu_crypt submit_from_crypt_cpus
772ae5f5
MB
72
73allow_discards
74 Block discard requests (a.k.a. TRIM) are passed through the crypt device.
75 The default is to ignore discard requests.
76
77 WARNING: Assess the specific security risks carefully before enabling this
78 option. For example, allowing discards on encrypted devices may lead to
79 the leak of information about the ciphertext device (filesystem type,
80 used space etc.) if the discarded blocks can be located easily on the
81 device later.
82
f3396c58
MP
83same_cpu_crypt
84 Perform encryption using the same cpu that IO was submitted on.
85 The default is to use an unbound workqueue so that encryption work
86 is automatically balanced between available CPUs.
87
0f5d8e6e
MP
88submit_from_crypt_cpus
89 Disable offloading writes to a separate thread after encryption.
90 There are some situations where offloading write bios from the
91 encryption threads to a single thread degrades performance
92 significantly. The default is to offload write bios to the same
93 thread because it benefits CFQ to have writes submitted using the
94 same context.
95
e3dcc5a3
MB
96Example scripts
97===============
98LUKS (Linux Unified Key Setup) is now the preferred way to set up disk
99encryption with dm-crypt using the 'cryptsetup' utility, see
e44f23b3 100https://gitlab.com/cryptsetup/cryptsetup
e3dcc5a3
MB
101
102[[
103#!/bin/sh
104# Create a crypt device using dmsetup
95f21c5c 105dmsetup create crypt1 --table "0 `blockdev --getsz $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
e3dcc5a3
MB
106]]
107
c538f6ec
OK
108[[
109#!/bin/sh
110# Create a crypt device using dmsetup when encryption key is stored in keyring service
111dmsetup create crypt2 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 :32:logon:my_prefix:my_key 0 $1 0"
112]]
113
e3dcc5a3
MB
114[[
115#!/bin/sh
116# Create a crypt device using cryptsetup and LUKS header with default cipher
117cryptsetup luksFormat $1
118cryptsetup luksOpen $1 crypt1
119]]