dm-crypt.txt 3.4 KB

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