Cryptsetup howto container
For non-systemd systems you will need to find a different way to run partprobe before the partitions are mounted. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question. Asked 3 years, 1 month ago.
Active 2 years, 4 months ago. Viewed 3k times. Is it possible to have multiple partitions in a single LUKS or cryptsetup container? If so, how?
The passphrase to be removed can be specified interactively, as positional argument or via --key-file. Removing the last passphrase makes the LUKS container permanently inaccessible. Changes an existing passphrase. The passphrase to be changed must be supplied interactively or via --key-file. The new passphrase can be supplied interactively or in a file given as positional argument. If a key-slot is specified via --key-slot , the passphrase for that key-slot must be given and the new passphrase will overwrite the specified key-slot.
If no key-slot is specified and there is still a free key-slot, then the new passphrase will be put into a free key-slot before the key-slot containing the old passphrase is purged.
If there is no free key-slot, then the key-slot with the old passphrase is overwritten directly. A remaining passphrase must be supplied, either interactively or via --key-file. This command can remove the last remaining key-slot, but requires an interactive confirmation when doing so.
Removing the last passphrase makes a LUKS container permanently inaccessible. Use option -v to get human-readable feedback. If the --dump-master-key option is used, the LUKS device master key is dumped instead of the keyslot info.
Beware that the master key cannot be changed and can be used to decrypt the data stored in the LUKS container without a passphrase and even without the LUKS header.
This means that if the master key is compromised, the whole device has to be erased to prevent further access. Use this option carefully. In order to dump the master key, a passphrase has to be supplied, either interactively or via --key-file. Stores a binary backup of the LUKS header and keyslot area. Also note that with a header backup you lose the ability to securely wipe the LUKS device by just overwriting the header and key-slots.
You either need to securely erase all header backups in addition or overwrite the encrypted data area as well. The second option is less secure, as some sectors can survive, e. Restores a binary backup of the LUKS header and keyslot area from the specified file.
This command requires that the master key size and data offset of the LUKS header already on the device and of the header backup match. Alternatively, if there is no LUKS header on the device, the backup will also be written to it. This command is useful to fix some known benign LUKS metadata header corruptions. Only basic corruptions of unused keyslot are fixable.
This command will only change the LUKS header, not any key-slot data. Cryptsetup is usually used directly on a block device disk partition or LVM volume. However, if the device argument is a file, cryptsetup tries to allocate a loopback device and map it into this file.
This mode requires Linux kernel 2. Of course, you can always map a file to a loop-device manually. See the cryptsetup FAQ for an example. When device mapping is active, you can see the loop backing file in the status command output. Also see losetup 8. Make sure you keep your passphrases safe. There are a few nice tricks for constructing a fallback, when suddenly out of the blue, your brain refuses to cooperate. Still, if your attacker model does not prevent it, storing your passphrase in a sealed envelope somewhere may be a good idea as well.
From a terminal : The passphrase is read until the first newline and then processed by PBKDF2 without the newline character. From stdin : LUKS will read passphrases from stdin up to the first newline character or the compiled-in maximum key file length. If --keyfile-size is given, it is ignored. From key file : The complete keyfile is read up to the compiled-in maximum size.
Newline characters do not terminate the input. The --keyfile-size option can be used to limit what is read. Passphrase processing : Whenever a passphrase is added to a LUKS header luksAddKey, luksFormat , the user may specify how much the time the passphrase processing should consume. The time is used to determine the iteration count for PBKDF2 and higher times will offer better protection for low-entropy passphrases, but luksOpen will take longer to complete.
For passphrases that have entropy higher than the used key length, higher iteration times will not increase security. The default setting of one second is sufficient for most practical cases. The only exception is a low-entropy passphrase used on a slow device. Note that no iterated hashing or salting is done in plain mode. If hashing is done, it is a single direct hash. This means that low-entropy passphrases are easy to attack in plain mode.
From a terminal : The passphrase is read until the first newline, i. The input without the newline character is processed with the default hash or the hash specified with --hash.
The has result will be truncated to the key size of the used cipher, or the size specified with -s. From stdin : Reading will continue until a newline or until the maximum input size is reached , with the trailing newline stripped. Choose a keyfile that will be used to encrypt and unlock the image. You can use an existing file like a photo, an mp3, or any other file. I am creating a long random keyfile. You can name it whatever you want.
Now we will encrypt our disk image file. This command requires that the master key size and data offset of the LUKS header already on the device and of the header backup match. Alternatively, if there is no LUKS header on the device, the backup will also be written to it. Use --offset to specify device offset. Note that the units need to be specified in number of byte sectors. Use --skip to specify the IV offset. If the original device used an offset and but did not use it in IV sector calculations, you have to explicitly use --skip 0 in addition to the offset parameter.
Use --hash to override the default hash function for passphrase hashing otherwise it is detected according to key size. Cryptsetup should recognize all header variants, except legacy cipher chains using LRW encryption mode with 64 bits encryption block namely Blowfish in LRW mode is not recognized, this is limitation of kernel crypto API.
To map system device device with boot loader where the whole encrypted system resides use --tcrypt-system option. You can use partition device as the parameter parameter must be real partition device, not image in file , then only this partition is mapped. If you have whole TCRYPT device as a file image and you want to map multiple partition encrypted with system encryption, please create loopback mapping with partitions first losetup -P , see losetup 8 man page for more info , and use loop partition as the device parameter.
If you use whole base device as parameter, one device for the whole system encryption is mapped. This mode is available only for backward compatibility with older cryptsetup versions which mapped TCRYPT system encryption using whole device. To use hidden header and map hidden device, if available , use --tcrypt-hidden option. To explicitly use backup secondary header, use --tcrypt-backup option. NOTE: There is no protection for a hidden volume if the outer volume is mounted. The reason is that if there were any protection, it would require some metadata describing what to protect in the outer volume and the hidden volume would become detectable.
The keyfile parameter allows combination of file content with the passphrase and can be repeated. For normal mapping it can cause destruction of hidden volume hidden volume appears as unused space for outer volume so this space can be discarded. Beware that the master key or concatenated master keys if cipher chain is used can be used to decrypt the data stored in the TCRYPT container without a passphrase.
Please note that cryptsetup does not use TrueCrypt code, please report all problems related to this compatibility extension to cryptsetup project.
Currently supported only for LUKS device type. This command is useful to fix some known benign LUKS metadata header corruptions. Only basic corruptions of unused keyslot are fixable.
This command will only change the LUKS header, not any key-slot data. Without parameters it tries to measure few common configurations. To benchmark other ciphers or modes, you need to specify --cipher and --key-size options or --hash for KDF test. NOTE: This benchmark is using memory only and is only informative.
You cannot directly predict real storage encryption speed from it. For testing block ciphers, this benchmark requires kernel userspace crypto API to be available introduced in Linux kernel 2. Debug output lines are always prefixed by ' '. The specified hash name is passed to the compiled-in crypto backend. Different backends may support different hashes. For luksFormat , the hash algorithm must provide at least bits of output, which excludes, e.
Do not use a non- crypto hash like "crc32" as this breaks security. Values compatible with old version of cryptsetup are "ripemd" for open --type plain and "sha1" for luksFormat. Use cryptsetup --help to show the defaults. The current default in the distributed sources is "aes-cbc-essiv:sha" for plain dm-crypt and "aes-xts- plain64" for LUKS. If a hash is part of the cipher spefification, then it is used as part of the IV generation.
For XTS mode you can optionally set a key size of bits with the -s option. Key size for XTS mode is twice that for other modes for the same security level. XTS mode requires kernel 2.
More information can be found in the FAQ. Advised when creating a regular mapping for the first time, or when running luksFormat. Ignored on input from file or stdin. If the name given is "-", then the passphrase will be read from stdin. In this case, reading will not stop at newline characters. With LUKS, passphrases supplied via --key-file are always the existing passphrases requested by a command, except in the case of luksFormat where --key-file is equivalent to the positional key file argument.
If you want to set a new passphrase via key file, you have to use a positional argument to luksAddKey. Works with all commands that accepts key files. Default is to read the whole file up to the compiled-in maximum that can be queried with --help. Supplying more data than the compiled-in maximum aborts the operation.
This option is useful to cut trailing newlines, for example. If --keyfile-offset is also given, the size count starts after the offset. Default is to read the whole file up to the compiled-in maximum length that can be queried with --help. Supplying more than the compiled in maximum aborts the operation. When --new-keyfile-offset is also given, reading starts after the offset.
0コメント