Difference between revisions of "Dm-crypt"

From ArchWiki
Jump to: navigation, search
m (Overview: there's not only QEMU)
m (Swap device encryption: grammar)
 
(49 intermediate revisions by 14 users not shown)
Line 1: Line 1:
 
{{Lowercase title}}
 
{{Lowercase title}}
[[Category:Security]]
+
[[Category:Encryption]]
 
[[Category:File systems]]
 
[[Category:File systems]]
[[de:ArchLinux mit verschlüsseltem LVM und Systemd]]
+
[[de:dm-crypt]]
 +
[[es:Dm-crypt]]
 
[[fr:LUKS]]
 
[[fr:LUKS]]
 +
[[it:Dm-crypt with LUKS]]
 +
[[ja:Dm-crypt]]
 
[[ru:System Encryption with LUKS]]
 
[[ru:System Encryption with LUKS]]
[[zh-CN:System Encryption with LUKS]]
+
[[zh-CN:Dm-crypt]]
{{Stub|1=This article is a work in progress: for its latest stable revision see [[Dm-crypt with LUKS]].}}
+
 
{{Related articles start}}
 
{{Related articles start}}
{{Related|Disk Encryption}}
+
{{Related|Disk encryption}}
 
{{Related|Removing System Encryption}}
 
{{Related|Removing System Encryption}}
{{Related|Plain dm-crypt without LUKS}}
 
 
{{Related articles end}}
 
{{Related articles end}}
  
{{Out of date|The introduction has to be rewritten after merging [[Plain dm-crypt without LUKS]]. <br> Before publishing the new article, double check all the link#fragments among the subpages.}}
+
From the cryptsetup project's [https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt wiki]:
This article focuses on how to set up full system encryption on Arch Linux, using dm-crypt with LUKS.
+
  
'''dm-crypt''' is the standard device-mapper encryption functionality provided by the Linux kernel. It can be used directly by those who like to have full control over all aspects of partition and key management.
+
:Device-mapper is infrastructure in the Linux 2.6 and 3.x kernel that provides a generic way to create virtual layers of block devices. Device-mapper crypt target provides transparent encryption of block devices using the kernel crypto API. The user can basically specify one of the symmetric ciphers, an encryption mode, a key (of any allowed size), an iv generation mode and then the user can create a new block device in /dev. Writes to this device will be encrypted and reads decrypted. You can mount your filesystem on it as usual or stack dm-crypt device with another device like RAID or LVM volume. Basic documentation of dm-crypt mapping table comes with kernel source and the latest version is available in git repository.
 
+
'''LUKS''' is an additional convenience layer which stores all of the needed setup information for dm-crypt on the disk itself and abstracts partition and key management in an attempt to improve ease of use.
+
 
+
For more details on how dm-crypt+LUKS compares to other disk encryption solution, see [[Disk Encryption#Comparison table]].
+
 
+
== Overview ==
+
{{Warning|Encrypting a disk or partition will erase everything currently on that disk or partition, make appropriate data backups prior to starting.
+
Also be aware that encrypting a system might not only make the life of laptop thieves more miserable, but also yours if you don't plan ahead on:
+
* how to make secure backups of the encrypted system/-setup/data and
+
* how to access the encrypted system manually for maintenance.
+
Keeping those points in mind while deciding on how to use encryption may help to decide on method and tools as well.}}
+
 
+
The installation of a LUKS-encrypted system is largely the same as installing an unencrypted system. Routine creation of an encrypted system follows these general steps:
+
 
+
* [[#Drive preparation|Preparation]] of the drive(s) where the system will be installed
+
* Creation of the needed [[#Device encryption|encryption layers]]
+
* [[#System configuration|Configuration]] of the system to handle the encryption
+
* Installation of the system following the [[Installation Guide]] or the [[Beginners' Guide]]
+
 
+
Note that the Arch installation media comes with all the tools required for system encryption.
+
 
+
{{Tip|You may want to practise encrypting a virtual hard drive in a [[:Category:Virtualization|virtual machine]] when learning.}}
+
  
 
==Common scenarios==
 
==Common scenarios==
===Encrypting a non-root filesystem===
+
This part introduces common scenarios to employ ''dm-crypt'' to encrypt a system or individual filesystem mount points. It is meant as starting point to familiarize with different practical encryption procedures. The scenarios cross-link to the other subpages where needed. 
''Main article: [[Dm-crypt/Encrypting a non-root file system]]''
+
  
Encrypting a secondary filesystem usually protects only sensitive data, while leaving the operating system and program files unencrypted. This is useful for encrypting an external medium, such as a USB drive, so that it can be moved to different computers securely. One might also choose to encrypt sets of data separately according to who has access to it. For example, in the case of a computer that has multiple users, each user's home directory may be encrypted separately to ensure that users can not access each others' data, while still having access to the system and public files.
+
See [[Dm-crypt/Encrypting a non-root file system]] if you need to encrypt a device that is not used for booting a system, like a [[Dm-crypt/Encrypting a non-root file system#Partition|partition]] or a [[Dm-crypt/Encrypting a non-root file system#Loop device|loop device]].
  
Although encrypting a non-root filesystem is possible with dm-crypt, there are more flexible and user friendly ways to achieve the same result. Because dm-crypt is a [[Disk Encryption#Block_device_encryption|block-level]] encryption layer, it only encrypts [[Dm-crypt/Encrypting_a_non-root_file_system#Partition|partitions]] and [[Dm-crypt/Encrypting_a_non-root_file_system#Loop_device|loop devices]]. To encrypt individual files requires a filesystem-level encryption layer, such as [[eCryptfs]] or [[EncFS]]. See [[Disk Encryption]] for general information about securing private data.
+
See [[Dm-crypt/Encrypting an entire system]] if you want to encrypt an entire system, in particular a root partition. Several scenarios are covered, including the use of ''dm-crypt'' with the ''LUKS'' extension, ''plain'' mode encryption and encryption and ''LVM''.
 
+
===Encrypting an entire system===
+
''Main article: [[Dm-crypt/Encrypting an entire system]]''
+
 
+
Securing a root filesystem, on the other hand, is where dm-crypt excels. When a system's root filesystem is on a dm-crypt device, nearly every file on the system is encrypted. Unlike selectively encrypting non-root filesystems, an encrypted root filesystem can conceal information such as which programs are installed, the usernames of all user accounts, and common data-leakage vectors such as [[mlocate]] and {{ic|/var/log/}}. Furthermore, an encrypted root filesystem makes tampering with the system far more difficult, as everything except the [[boot loader]] and kernel is encrypted.
+
 
+
In encrypted root filesystem scenarios, dm-crypt is often combined with other disk abstraction technologies such as [[Dm-crypt/Encrypting_an_entire_system#LVM_on_LUKS|LVM]] and [[Dm-crypt/Encrypting_an_entire_system#LUKS_on_software_RAID|RAID]], although it is by no means necessary.
+
 
+
While an encrypted root filesystem provides much greater protection from outside threats than encrypted secondary filesystems, any user of the system is able to decrypt the entire drive, and therefore can access other users' data. However, it is possible to use a combination of root and non-root filesystem encryption and reap the advantages of both. It is important to balance the benefits with the effort, as an encrypted root filesystem is more difficult to setup than an encrypted secondary filesystem.
+
  
 
==Drive preparation==
 
==Drive preparation==
This step will deal with operations like [[Dm-crypt/Drive Preparation#Secure erasure of the hard disk drive|securely erasing the drive]] and [[Dm-crypt/Drive Preparation#Partitioning|partitioning it]].
+
[[Dm-crypt/Drive preparation]] deals with operations like [[Dm-crypt/Drive preparation#Secure erasure of the hard disk drive|securely erasing the drive]] and ''dm-crypt'' specific points for [[Dm-crypt/Drive preparation#Partitioning|partitioning it]].  
 
+
See [[Dm-crypt/Drive Preparation]].
+
  
 
==Device encryption==
 
==Device encryption==
{{Expansion|Add some introductory text with links to the most important subsections of [[Dm-crypt/Device Encryption]].}}
+
[[Dm-crypt/Device encryption]] covers how to manually utilize dm-crypt to encrypt a system through the [[dm-crypt/Device encryption#Cryptsetup usage|cryptsetup]] command. It covers examples of the [[Dm-crypt/Device encryption#Encryption options with dm-crypt|Encryption options with dm-crypt]], deals with the creation of [[dm-crypt/Device encryption#Keyfiles|keyfiles]], LUKS specific commands for [[Dm-crypt/Device_encryption#Key_management|key management]] as well as for  [[Dm-crypt/Device_encryption#Backup_and_restore|Backup and restore]].  
See [[Dm-crypt/Device Encryption]].
+
  
 
==System configuration==
 
==System configuration==
{{Expansion|Add some introductory text with links to the most important subsections of [[Dm-crypt/System Configuration]].}}
+
[[Dm-crypt/System configuration]] illustrates how to configure [[Dm-crypt/System configuration#mkinitcpio|mkinitcpio]], the [[Dm-crypt/System configuration#Boot loader|boot loader]] and the [[Dm-crypt/System configuration#crypttab|crypttab]] file when encrypting a system.
See [[Dm-crypt/System Configuration]].
+
  
 
==Swap device encryption==
 
==Swap device encryption==
A swap partition may be added to an encrypted system, if required. The swap partition must be encrypted as well to protect any data swapped out by the system. This part details methods [[Dm-crypt_with_LUKS/Swap_Encryption#Without_suspend-to-disk_support|without]] and [[Dm-crypt_with_LUKS/Swap_Encryption#With_suspend-to-disk_support|with]] suspend-to-disk support.
+
[[Dm-crypt/Swap encryption]] covers how to add a swap partition to an encrypted system, if required. The swap partition must be encrypted as well to protect any data swapped out by the system. This part details methods [[Dm-crypt_with_LUKS/Swap_Encryption#Without_suspend-to-disk_support|without]] and [[Dm-crypt_with_LUKS/Swap_Encryption#With_suspend-to-disk_support|with]] suspend-to-disk support.
 
+
See [[Dm-crypt/Swap Encryption]].
+
  
 
==Specialties==
 
==Specialties==
This part deals with special operations like [[Dm-crypt/Specialties#Securing the unencrypted boot partition|securing the unencrypted boot partition]], [[Dm-crypt/Specialties#Using GPG or OpenSSL Encrypted Keyfiles|using GPG or OpenSSL encrypted keyfiles]], a method to [[Dm-crypt/Specialties#Using GPG or OpenSSL Encrypted Keyfiles|boot and unlock via the network]], or [[Dm-crypt/Specialties#Using GPG or OpenSSL Encrypted Keyfiles|setting up discard/TRIM for a SSD]].
+
[[Dm-crypt/Specialties]] deals with special operations like [[Dm-crypt/Specialties#Securing the unencrypted boot partition|securing the unencrypted boot partition]], [[Dm-crypt/Specialties#Using GPG or OpenSSL Encrypted Keyfiles|using GPG or OpenSSL encrypted keyfiles]], a method to [[Dm-crypt/Specialties#Remote_unlocking_of_the_root_.28or_other.29_partition|boot and unlock via the network]], another for [[Dm-crypt/Specialties#Discard.2FTRIM_support_for_solid_state_drives_.28SSD.29|setting up discard/TRIM for a SSD]], and sections dealing with [[Dm-crypt/Specialties#The_encrypt_hook_and_multiple_disks|the encrypt hook and multiple disks]].  
 
+
See [[Dm-crypt/Specialties]].
+
  
 
== See also ==
 
== See also ==
* [http://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions cryptsetup FAQ] - The main and foremost help resource, directly from the developers.
+
* [https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt dm-crypt] - The project homepage
* [http://www.freeotfe.org/ FreeOTFE] - Supports unlocking LUKS encrypted volumes in Microsoft Windows.
+
* [https://gitlab.com/cryptsetup/cryptsetup cryptsetup] - The LUKS homepage and [https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions FAQ] - the main and foremost help resource.  
 +
* [https://git.kernel.org/cgit/utils/cryptsetup/cryptsetup.git/ cryptsetup repository] and [https://www.kernel.org/pub/linux/utils/cryptsetup/ release] archive.
 +
* [https://github.com/t-d-k/doxbox DOXBOX] - Supports unlocking LUKS encrypted volumes in Microsoft Windows.

Latest revision as of 08:47, 15 February 2016

From the cryptsetup project's wiki:

Device-mapper is infrastructure in the Linux 2.6 and 3.x kernel that provides a generic way to create virtual layers of block devices. Device-mapper crypt target provides transparent encryption of block devices using the kernel crypto API. The user can basically specify one of the symmetric ciphers, an encryption mode, a key (of any allowed size), an iv generation mode and then the user can create a new block device in /dev. Writes to this device will be encrypted and reads decrypted. You can mount your filesystem on it as usual or stack dm-crypt device with another device like RAID or LVM volume. Basic documentation of dm-crypt mapping table comes with kernel source and the latest version is available in git repository.

Common scenarios

This part introduces common scenarios to employ dm-crypt to encrypt a system or individual filesystem mount points. It is meant as starting point to familiarize with different practical encryption procedures. The scenarios cross-link to the other subpages where needed.

See Dm-crypt/Encrypting a non-root file system if you need to encrypt a device that is not used for booting a system, like a partition or a loop device.

See Dm-crypt/Encrypting an entire system if you want to encrypt an entire system, in particular a root partition. Several scenarios are covered, including the use of dm-crypt with the LUKS extension, plain mode encryption and encryption and LVM.

Drive preparation

Dm-crypt/Drive preparation deals with operations like securely erasing the drive and dm-crypt specific points for partitioning it.

Device encryption

Dm-crypt/Device encryption covers how to manually utilize dm-crypt to encrypt a system through the cryptsetup command. It covers examples of the Encryption options with dm-crypt, deals with the creation of keyfiles, LUKS specific commands for key management as well as for Backup and restore.

System configuration

Dm-crypt/System configuration illustrates how to configure mkinitcpio, the boot loader and the crypttab file when encrypting a system.

Swap device encryption

Dm-crypt/Swap encryption covers how to add a swap partition to an encrypted system, if required. The swap partition must be encrypted as well to protect any data swapped out by the system. This part details methods without and with suspend-to-disk support.

Specialties

Dm-crypt/Specialties deals with special operations like securing the unencrypted boot partition, using GPG or OpenSSL encrypted keyfiles, a method to boot and unlock via the network, another for setting up discard/TRIM for a SSD, and sections dealing with the encrypt hook and multiple disks.

See also