'\" t .\" Title: cryptsetup-luksformat .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.23 .\" Date: 2025-08-13 .\" Manual: Maintenance Commands .\" Source: cryptsetup 2.8.1 .\" Language: English .\" .TH "CRYPTSETUP\-LUKSFORMAT" "8" "2025-08-13" "cryptsetup 2.8.1" "Maintenance Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" cryptsetup-luksFormat \- initialize a LUKS partition and set the initial passphrase .SH "SYNOPSIS" .sp \fBcryptsetup \fIluksFormat\fP [] []\fP .SH "DESCRIPTION" .sp Initializes a LUKS partition and sets the passphrase via prompting or . Note that if the second argument is present, the passphrase is taken from the file given there, without using the \-\-key\-file option. Also note that for both forms of reading the passphrase from a file, you can give \*(Aq\-\*(Aq as a file name, which results in the passphrase being read from stdin and the safety question being skipped. .sp You cannot call luksFormat on a device or filesystem that is mapped or in use, e.g., a mounted filesystem, used in LVM, active RAID member, etc. The device or filesystem has to be unmounted in order to call luksFormat. .sp To enforce a specific version of LUKS format, use \fI\-\-type luks1\fP or \fItype luks2\fP. The default format is LUKS2. .sp To use hardware encryption on an OPAL self\-encrypting drive, use \-\-hw\-opal or \-\-hw\-opal\-only. Note that some OPAL drives can require a PSID reset (with deletion of data) before using the LUKS format with OPAL options. See \-\-hw\-opal\-factory\-reset option in cryptsetup \fIerase\fP command. .sp Doing a luksFormat on an existing LUKS container will regenerate the volume key. Unless you have a header backup, all old encrypted data in the container will be permanently irretrievable. Note that luksFormat does not wipe or overwrite the data area. It only creates a new LUKS header with fresh keyslots. See cryptsetup FAQ for more info on how to wipe the whole device, including encrypted data. .sp \fB\fP can be [\-\-hash, \-\-cipher, \-\-verify\-passphrase, \-\-key\-size, \-\-key\-slot, \-\-key\-file (takes precedence over optional second argument), \-\-keyfile\-offset, \-\-keyfile\-size, \-\-use\-random, \-\-use\-urandom, \-\-uuid, \-\-volume\-key\-file, \-\-iter\-time, \-\-header, \-\-pbkdf\-force\-iterations, \-\-force\-password, \-\-disable\-locks, \-\-timeout, \-\-type, \-\-offset, \-\-align\-payload (DEPRECATED)]. .sp For LUKS2, additional \fB\fP can be [\-\-integrity, \-\-integrity\-no\-wipe, \-\-sector\-size, \-\-label, \-\-subsystem, \-\-pbkdf, \-\-pbkdf\-memory, \-\-pbkdf\-parallel, \-\-disable\-locks, \-\-disable\-keyring, \-\-luks2\-metadata\-size, \-\-luks2\-keyslots\-size, \-\-keyslot\-cipher, \-\-keyslot\-key\-size, \-\-integrity\-legacy\-padding, \-\-hw\-opal, \-\-hw\-opal\-only]. .SH "OPTIONS" .sp \fB\-\-align\-payload\fP \fI\fP (DEPRECATED, use \-\-offset) .RS 4 Align payload at a boundary of \fIvalue\fP 512\-byte sectors. .sp If not specified, cryptsetup tries to use the topology info provided by the kernel for the underlying device to get the optimal alignment. If not available (or the calculated value is a multiple of the default), data is by default aligned to a 1MiB boundary (i.e., 2048 512\-byte sectors). .sp For a detached LUKS header, this option specifies the offset on the data device. See also the \-\-header option. .sp This option is DEPRECATED and has an unexpected impact on the data offset and keyslot area size (for LUKS2) due to the complex rounding. For fixed data device offset, use \-\-offset option instead. .RE .sp \fB\-\-batch\-mode\fP, \fB\-q\fP .RS 4 Suppresses all confirmation questions. Use with care! .sp If the \-\-verify\-passphrase option is not specified, this option also switches off the passphrase verification. .RE .sp \fB\-\-cipher\fP, \fB\-c\fP \fI\fP .RS 4 Set the cipher specification string. .sp \fIcryptsetup \-\-help\fP shows the compiled\-in defaults. .sp If a hash is part of the cipher specification, then it is used as part of the IV generation. For example, ESSIV needs a hash function, while "plain64" does not and hence none is specified. .sp For XTS mode, you can optionally set a key size of 512 bits with the \-s option. Key size for XTS mode is twice that for other modes for the same security level. .RE .sp \fB\-\-debug\fP or \fB\-\-debug\-json\fP .RS 4 Run in debug mode with full diagnostic logs. Debug output lines are always prefixed by \fB#\fP. .sp If \-\-debug\-json is used, additional LUKS2 JSON data structures are printed. .RE .sp \fB\-\-disable\-blkid\fP .RS 4 Disable use of the blkid library for checking and wiping on\-disk signatures. .RE .sp \fB\-\-disable\-keyring\fP .RS 4 Do not load the volume key in the kernel keyring; store it directly in the dm\-crypt target instead. This option is supported only for the LUKS2 type. .RE .sp \fB\-\-disable\-locks\fP .RS 4 Disable lock protection for metadata on disk. This option is valid only for LUKS2 and is ignored for other formats. .sp \fBWARNING:\fP Do not use this option unless you run cryptsetup in a restricted environment where locking is impossible to perform (where /run directory cannot be used). .RE .sp \fB\-\-force\-password\fP .RS 4 Do not use password quality checking for new LUKS passwords. .sp This option is ignored if cryptsetup is built without password quality checking support. .sp For more info about password quality check, see the manual page for \fBpwquality.conf\fP(5) and \fBpasswdqc.conf\fP(5). .RE .sp \fB\-\-hash\fP, \fB\-h\fP \fI\fP .RS 4 Specifies the hash used in the LUKS key setup scheme and volume key digest. The specified hash is used for PBKDF2 and the AF splitter. .sp The hash algorithm must provide at least 160 bits of output. Do not use a non\-crypto hash like \fBxxhash\fP as this breaks security. Use \fIcryptsetup \-\-help\fP to show the defaults. .RE .sp \fB\-\-header\fP \fI\fP .RS 4 Use a detached (separated) metadata device or file where the LUKS header is stored. This option allows one to store the ciphertext and LUKS header on different devices. .sp With a file name as the argument to \-\-header, the file will be automatically created if it does not exist. See the cryptsetup FAQ for header size calculation. .sp The \-\-align\-payload option is taken as absolute sector alignment on the ciphertext device and can be zero. .RE .sp \fB\-\-help\fP, \fB\-?\fP .RS 4 Show help text and default parameters. .RE .sp \fB\-\-hw\-opal\fP .RS 4 Format LUKS2 device with dm\-crypt encryption stacked on top of HW\-based encryption configured on SED OPAL locking range. This option enables both SW and HW based data encryption. .RE .sp \fB\-\-hw\-opal\-only\fP .RS 4 Format LUKS2 device with HW based encryption configured on SED OPAL locking range only. LUKS2 format only manages the locking range unlock key. This option enables HW\-based data encryption managed by the SED OPAL drive only. .sp Please note that with OPAL\-only (\-\-hw\-opal\-only) encryption, the configured OPAL administrator PIN (passphrase) allows unlocking all configured locking ranges without LUKS keyslot decryption (without knowledge of LUKS passphrase). Because of many observed problems with compatibility, cryptsetup currently DOES NOT use OPAL single\-user mode, which would allow such decoupling of OPAL admin PIN access. .RE .sp \fB\-\-integrity\fP \fI\fP .RS 4 Specify the integrity algorithm to be used for authenticated disk encryption in LUKS2. .sp \fBWARNING: This extension is EXPERIMENTAL\fP and requires dm\-integrity kernel target. For native AEAD modes, also enable "User\-space interface for AEAD cipher algorithms" in the "Cryptographic API" section (CONFIG_CRYPTO_USER_API_AEAD .config option). .sp For more info, see the \fIAUTHENTICATED DISK ENCRYPTION\fP section in \fBcryptsetup\fP(8). .RE .sp \fB\-\-integrity\-inline\fP .RS 4 Store integrity tags in hardware sector integrity fields. The device must support sectors with additional protection information (PI, also known as DIF \- data integrity field) of the requested size. Another storage subsystem must not use the additional field (the device must present a "nop" profile in the kernel). Note that some devices must be reformatted at a low level to support this option; for NVMe devices, see nvme(1) id\-ns LBA profiles. .sp No journal or bitmap is used in this mode. The device should operate with native speed (without any overhead). This option is available since the Linux kernel version 6.11. .RE .sp \fB\-\-integrity\-key\-size\fP \fIbytes\fP .RS 4 The size of the data integrity key. Configurable only for HMAC integrity. The default integrity key size is set to the same as the hash output length. .RE .sp \fB\-\-integrity\-legacy\-padding\fP .RS 4 Use inefficient legacy padding. .sp Do not use this option until you need compatibility with a specific old kernel. .RE .sp \fB\-\-integrity\-no\-wipe\fP .RS 4 Skip wiping of device authentication (integrity) tags. If you skip this step, sectors will report an invalid integrity tag until an application writes to the sector. .sp Skipping this step could also cause write failures due to IO operation alignments. For example, kernel page cache can request a read of a full page that fails due to an uninitialized integrity tag. It is usually a bug in the application that tries to read data that was not written before. .RE .sp \fB\-\-iter\-time\fP, \fB\-i\fP \fI\fP .RS 4 The number of milliseconds to spend with PBKDF passphrase processing. Specifying 0 as a parameter selects the compiled\-in default. .RE .sp \fB\-\-key\-description\fP \fItext\fP .RS 4 Set the key description in the keyring that will be used for passphrase retrieval. .RE .sp \fB\-\-key\-file\fP, \fB\-d\fP \fIfile\fP .RS 4 Read the passphrase from the file. .sp If the name given is "\-", then the passphrase will be read from stdin. In this case, reading will not stop at newline characters. .sp See section \fINOTES ON PASSPHRASE PROCESSING\fP in \fBcryptsetup\fP(8) for more information. .RE .sp \fB\-\-keyfile\-offset\fP \fIvalue\fP .RS 4 Skip \fIvalue\fP bytes at the beginning of the key file. .RE .sp \fB\-\-keyfile\-size\fP, \fB\-l\fP \fIvalue\fP .RS 4 Read a maximum of \fIvalue\fP bytes from the key file. The 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. .sp This option is useful to cut trailing newlines, for example. If \-\-keyfile\-offset is also given, the size count starts after the offset. .RE .sp \fB\-\-key\-size\fP, \fB\-s\fP \fIbits\fP .RS 4 Sets key size in \fIbits\fP. The argument has to be a multiple of 8. The possible key sizes are limited by the cipher and mode used. .sp See /proc/crypto for more information. Note that the key size in /proc/crypto is stated in bytes. .sp This option can be used for \fIopen \-\-type plain\fP or \fIluksFormat\fP. All other LUKS actions will use the key size specified in the LUKS header. Use \fIcryptsetup \-\-help\fP to show the compiled\-in defaults. .RE .sp \fB\-\-key\-slot\fP, \fB\-S\fP \fI<0\-N>\fP .RS 4 For LUKS operations that add key material, this option allows you to specify which keyslot is selected for the new key. .sp The maximum number of keyslots depends on the LUKS version. LUKS1 can have up to 8 keyslots. LUKS2 can have up to 32 keyslots based on keyslot area size and key size, but a valid keyslot ID can always be between 0 and 31 for LUKS2. .RE .sp \fB\-\-keyslot\-cipher\fP \fI\fP .RS 4 This option can be used to set specific cipher encryption for the LUKS2 keyslot area. .RE .sp \fB\-\-keyslot\-key\-size\fP \fI\fP .RS 4 This option can be used to set a specific key size for the LUKS2 keyslot area. .RE .sp \fB\-\-label\fP \fI