1CRYPTSETUP-LUKSFORMAT(8)     Maintenance Commands     CRYPTSETUP-LUKSFORMAT(8)
2
3
4

NAME

6       cryptsetup-luksFormat - initialize a LUKS partition and set the initial
7       passphrase
8

SYNOPSIS

10       cryptsetup luksFormat [<options>] <device> [<key file>]
11

DESCRIPTION

13       Initializes a LUKS partition and sets the initial passphrase (for
14       key-slot 0), either via prompting or via <key file>. Note that if the
15       second argument is present, then the passphrase is taken from the file
16       given there, without the need to use the --key-file option. Also note
17       that for both forms of reading the passphrase from a file you can give
18       '-' as file name, which results in the passphrase being read from stdin
19       and the safety-question being skipped.
20
21       You cannot call luksFormat on a device or filesystem that is mapped or
22       in use, e.g., mounted filesystem, used in LVM, active RAID member, etc.
23       The device or filesystem has to be un-mounted in order to call
24       luksFormat.
25
26       To use specific version of LUKS format, use --type luks1 or type luks2.
27
28       <options> can be [--hash, --cipher, --verify-passphrase, --key-size,
29       --key-slot, --key-file (takes precedence over optional second
30       argument), --keyfile-offset, --keyfile-size, --use-random,
31       --use-urandom, --uuid, --volume-key-file, --iter-time, --header,
32       --pbkdf-force-iterations, --force-password, --disable-locks, --timeout,
33       --type, --offset, --align-payload (deprecated)].
34
35       For LUKS2, additional <options> can be [--integrity,
36       --integrity-no-wipe, --sector-size, --label, --subsystem, --pbkdf,
37       --pbkdf-memory, --pbkdf-parallel, --disable-locks, --disable-keyring,
38       --luks2-metadata-size, --luks2-keyslots-size, --keyslot-cipher,
39       --keyslot-key-size, --integrity-legacy-padding].
40
41       WARNING: Doing a luksFormat on an existing LUKS container will make all
42       data in the old container permanently irretrievable unless you have a
43       header backup.
44

OPTIONS

46       --type <device-type>
47           Specifies required device type, for more info read BASIC ACTIONS
48           section in cryptsetup(8).
49
50       --hash, -h <hash-spec>
51           Specifies the hash used in the LUKS key setup scheme and volume key
52           digest. The specified hash is used for PBKDF2 and AF splitter.
53
54           The hash algorithm must provide at least 160 bits of output. Do not
55           use a non-crypto hash like xxhash as this breaks security. Use
56           cryptsetup --help to show the defaults.
57
58       --cipher, -c <cipher-spec>
59           Set the cipher specification string.
60
61           cryptsetup --help shows the compiled-in defaults.
62
63           If a hash is part of the cipher specification, then it is used as
64           part of the IV generation. For example, ESSIV needs a hash
65           function, while "plain64" does not and hence none is specified.
66
67           For XTS mode you can optionally set a key size of 512 bits with the
68           -s option. Key size for XTS mode is twice that for other modes for
69           the same security level.
70
71       --verify-passphrase, -y
72           When interactively asking for a passphrase, ask for it twice and
73           complain if both inputs do not match. Ignored on input from file or
74           stdin.
75
76       --key-file, -d name
77           Read the passphrase from file.
78
79           If the name given is "-", then the passphrase will be read from
80           stdin. In this case, reading will not stop at newline characters.
81
82           See section NOTES ON PASSPHRASE PROCESSING in cryptsetup(8) for
83           more information.
84
85       --keyfile-offset value
86           Skip value bytes at the beginning of the key file.
87
88       --keyfile-size, -l value
89           Read a maximum of value bytes from the key file. The default is to
90           read the whole file up to the compiled-in maximum that can be
91           queried with --help. Supplying more data than the compiled-in
92           maximum aborts the operation.
93
94           This option is useful to cut trailing newlines, for example. If
95           --keyfile-offset is also given, the size count starts after the
96           offset.
97
98       --volume-key-file, --master-key-file (OBSOLETE alias)
99           Use a volume key stored in a file. WARNING: If you create your own
100           volume key, you need to make sure to do it right. Otherwise, you
101           can end up with a low-entropy or otherwise partially predictable
102           volume key which will compromise security.
103
104       --use-random, --use-urandom
105           For luksFormat these options define which kernel random number
106           generator will be used to create the volume key (which is a
107           long-term key).
108
109           See NOTES ON RANDOM NUMBER GENERATORS in cryptsetup(8) for more
110           information. Use cryptsetup --help to show the compiled-in default
111           random number generator.
112
113           WARNING: In a low-entropy situation (e.g. in an embedded system)
114           and older kernels, both selections are problematic. Using
115           /dev/urandom can lead to weak keys. Using /dev/random can block a
116           long time, potentially forever, if not enough entropy can be
117           harvested by the kernel.
118
119       --key-slot, -S <0-N>
120           For LUKS operations that add key material, this option allows you
121           to specify which key slot is selected for the new key.
122
123           The maximum number of key slots depends on the LUKS version. LUKS1
124           can have up to 8 key slots. LUKS2 can have up to 32 key slots based
125           on key slot area size and key size, but a valid key slot ID can
126           always be between 0 and 31 for LUKS2.
127
128       --key-size, -s bits
129           Sets key size in bits. The argument has to be a multiple of 8. The
130           possible key-sizes are limited by the cipher and mode used.
131
132           See /proc/crypto for more information. Note that key-size in
133           /proc/crypto is stated in bytes.
134
135           This option can be used for open --type plain or luksFormat. All
136           other LUKS actions will use the key-size specified in the LUKS
137           header. Use cryptsetup --help to show the compiled-in defaults.
138
139       --offset, -o <number of 512 byte sectors>
140           Start offset in the backend device in 512-byte sectors.
141
142           The --offset option sets the data offset (payload) of data device
143           and must be aligned to 4096-byte sectors (must be multiple of 8).
144           This option cannot be combined with --align-payload option.
145
146       --pbkdf <PBKDF spec>
147           Set Password-Based Key Derivation Function (PBKDF) algorithm for
148           LUKS keyslot. The PBKDF can be: pbkdf2 (for PBKDF2 according to
149           RFC2898), argon2i for Argon2i or argon2id for Argon2id (see Argon2
150           <https://www.cryptolux.org/index.php/Argon2> for more info).
151
152           For LUKS1, only PBKDF2 is accepted (no need to use this option).
153           The default PBKDF for LUKS2 is set during compilation time and is
154           available in cryptsetup --help output.
155
156           A PBKDF is used for increasing dictionary and brute-force attack
157           cost for keyslot passwords. The parameters can be time, memory and
158           parallel cost.
159
160           For PBKDF2, only time cost (number of iterations) applies. For
161           Argon2i/id, there is also memory cost (memory required during the
162           process of key derivation) and parallel cost (number of threads
163           that run in parallel during the key derivation.
164
165           Note that increasing memory cost also increases time, so the final
166           parameter values are measured by a benchmark. The benchmark tries
167           to find iteration time (--iter-time) with required memory cost
168           --pbkdf-memory. If it is not possible, the memory cost is decreased
169           as well. The parallel cost --pbkdf-parallel is constant and is
170           checked against available CPU cores.
171
172           You can see all PBKDF parameters for particular LUKS2 keyslot with
173           cryptsetup-luksDump(8) command.
174
175           NOTE: If you do not want to use benchmark and want to specify all
176           parameters directly, use --pbkdf-force-iterations with
177           --pbkdf-memory and --pbkdf-parallel. This will override the values
178           without benchmarking. Note it can cause extremely long unlocking
179           time. Use only in specific cases, for example, if you know that the
180           formatted device will be used on some small embedded system.
181
182           MINIMAL AND MAXIMAL PBKDF COSTS: For PBKDF2, the minimum iteration
183           count is 1000 and maximum is 4294967295 (maximum for 32bit unsigned
184           integer). Memory and parallel costs are unused for PBKDF2. For
185           Argon2i and Argon2id, minimum iteration count (CPU cost) is 4 and
186           maximum is 4294967295 (maximum for 32bit unsigned integer). Minimum
187           memory cost is 32 KiB and maximum is 4 GiB. (Limited by addressable
188           memory on some CPU platforms.) If the memory cost parameter is
189           benchmarked (not specified by a parameter) it is always in range
190           from 64 MiB to 1 GiB. The parallel cost minimum is 1 and maximum 4
191           (if enough CPUs cores are available, otherwise it is decreased).
192
193       --iter-time, -i <number of milliseconds>
194           The number of milliseconds to spend with PBKDF passphrase
195           processing. Specifying 0 as parameter selects the compiled-in
196           default.
197
198       --pbkdf-memory <number>
199           Set the memory cost for PBKDF (for Argon2i/id the number represents
200           kilobytes). Note that it is maximal value, PBKDF benchmark or
201           available physical memory can decrease it. This option is not
202           available for PBKDF2.
203
204       --pbkdf-parallel <number>
205           Set the parallel cost for PBKDF (number of threads, up to 4). Note
206           that it is maximal value, it is decreased automatically if CPU
207           online count is lower. This option is not available for PBKDF2.
208
209       --pbkdf-force-iterations <num>
210           Avoid PBKDF benchmark and set time cost (iterations) directly. It
211           can be used for LUKS/LUKS2 device only. See --pbkdf option for more
212           info.
213
214       --progress-frequency seconds
215           Print separate line every seconds with wipe progress.
216
217       --progress-json
218           Prints progress data in JSON format suitable mostly for machine
219           processing. It prints separate line every half second (or based on
220           --progress-frequency value). The JSON output looks as follows
221           during progress (except it’s compact single line):
222
223               {
224                 "device":"/dev/sda"       // backing device or file
225                 "device_bytes":"8192",    // bytes of I/O so far
226                 "device_size":"44040192", // total bytes of I/O to go
227                 "speed":"126877696",      // calculated speed in bytes per second (based on progress so far)
228                 "eta_ms":"2520012"        // estimated time to finish an operation in milliseconds
229                 "time_ms":"5561235"       // total time spent in IO operation in milliseconds
230               }
231
232           Note on numbers in JSON output: Due to JSON parsers limitations all
233           numbers are represented in a string format due to need of full
234           64bit unsigned integers.
235
236       --timeout, -t <number of seconds>
237           The number of seconds to wait before timeout on passphrase input
238           via terminal. It is relevant every time a passphrase is asked. It
239           has no effect if used in conjunction with --key-file.
240
241           This option is useful when the system should not stall if the user
242           does not input a passphrase, e.g. during boot. The default is a
243           value of 0 seconds, which means to wait forever.
244
245       --align-payload <number of 512 byte sectors>
246           Align payload at a boundary of value 512-byte sectors.
247
248           If not specified, cryptsetup tries to use the topology info
249           provided by the kernel for the underlying device to get the optimal
250           alignment. If not available (or the calculated value is a multiple
251           of the default) data is by default aligned to a 1MiB boundary (i.e.
252           2048 512-byte sectors).
253
254           For a detached LUKS header, this option specifies the offset on the
255           data device. See also the --header option.
256
257           WARNING: This option is DEPRECATED and has often unexpected impact
258           to the data offset and keyslot area size (for LUKS2) due to the
259           complex rounding. For fixed data device offset use --offset option
260           instead.
261
262       --uuid <UUID>
263           Use the provided UUID for the luksFormat command instead of
264           generating a new one. Changes the existing UUID when used with the
265           luksUUID command.
266
267           The UUID must be provided in the standard UUID format, e.g.
268           12345678-1234-1234-1234-123456789abc.
269
270       --header <device or file storing the LUKS header>
271           Use a detached (separated) metadata device or file where the LUKS
272           header is stored. This option allows one to store ciphertext and
273           LUKS header on different devices.
274
275           With a file name as the argument to --header, the file will be
276           automatically created if it does not exist. See the cryptsetup FAQ
277           for header size calculation.
278
279           The --align-payload option is taken as absolute sector alignment on
280           ciphertext device and can be zero.
281
282       --force-password
283           Do not use password quality checking for new LUKS passwords.
284
285           This option is ignored if cryptsetup is built without password
286           quality checking support.
287
288           For more info about password quality check, see the manual page for
289           pwquality.conf(5) and passwdqc.conf(5).
290
291       --disable-locks
292           Disable lock protection for metadata on disk. This option is valid
293           only for LUKS2 and ignored for other formats.
294
295           WARNING: Do not use this option unless you run cryptsetup in a
296           restricted environment where locking is impossible to perform
297           (where /run directory cannot be used).
298
299       --disable-keyring
300           Do not load volume key in kernel keyring and store it directly in
301           the dm-crypt target instead. This option is supported only for the
302           LUKS2 type.
303
304       --sector-size bytes
305           Set sector size for use with disk encryption. It must be power of
306           two and in range 512 - 4096 bytes. This option is available only
307           with LUKS2 format.
308
309           For LUKS2 devices it’s established based on parameters provided by
310           underlying data device. For native 4K block devices it’s 4096
311           bytes. For 4K/512e (4K physical sector size with 512 bytes
312           emulation) it’s 4096 bytes. For drives reporting only 512 bytes
313           block size it remains 512 bytes. If data device is regular file put
314           in filesystem it’s 4096 bytes.
315
316           Note that if sector size is higher than underlying device hardware
317           sector and there is not integrity protection that uses data
318           journal, using this option can increase risk on incomplete sector
319           writes during a power fail.
320
321           If used together with --integrity option and dm-integrity journal,
322           the atomicity of writes is guaranteed in all cases (but it cost
323           write performance - data has to be written twice).
324
325           Increasing sector size from 512 bytes to 4096 bytes can provide
326           better performance on most of the modern storage devices and also
327           with some hw encryption accelerators.
328
329       --label <LABEL> --subsystem <SUBSYSTEM>
330           Set label and subsystem description for LUKS2 device. The label and
331           subsystem are optional fields and can be later used in udev scripts
332           for triggering user actions once the device marked by these labels
333           is detected.
334
335       --integrity <integrity algorithm>
336           Specify integrity algorithm to be used for authenticated disk
337           encryption in LUKS2.
338
339           WARNING: This extension is EXPERIMENTAL and requires dm-integrity
340           kernel target (available since kernel version 4.12). For native
341           AEAD modes, also enable "User-space interface for AEAD cipher
342           algorithms" in "Cryptographic API" section
343           (CONFIG_CRYPTO_USER_API_AEAD .config option).
344
345           For more info, see AUTHENTICATED DISK ENCRYPTION section in
346           cryptsetup(8).
347
348       --integrity-legacy-padding
349           Use inefficient legacy padding.
350
351           WARNING: Do not use this option until you need compatibility with
352           specific old kernel.
353
354       --luks2-metadata-size <size>
355           This option can be used to enlarge the LUKS2 metadata (JSON) area.
356           The size includes 4096 bytes for binary metadata (usable JSON area
357           is smaller of the binary area). According to LUKS2 specification,
358           only these values are valid: 16, 32, 64, 128, 256, 512, 1024, 2048
359           and 4096 kB The <size> can be specified with unit suffix (for
360           example 128k).
361
362       --luks2-keyslots-size <size>
363           This option can be used to set specific size of the LUKS2 binary
364           keyslot area (key material is encrypted there). The value must be
365           aligned to multiple of 4096 bytes with maximum size 128MB. The
366           <size> can be specified with unit suffix (for example 128k).
367
368       --keyslot-cipher <cipher-spec>
369           This option can be used to set specific cipher encryption for the
370           LUKS2 keyslot area.
371
372       --keyslot-key-size <bits>
373           This option can be used to set specific key size for the LUKS2
374           keyslot area.
375
376       --integrity-no-wipe
377           Skip wiping of device authentication (integrity) tags. If you skip
378           this step, sectors will report invalid integrity tag until an
379           application write to the sector.
380
381           NOTE: Even some writes to the device can fail if the write is not
382           aligned to page size and page-cache initiates read of a sector with
383           invalid integrity tag.
384
385       --batch-mode, -q
386           Suppresses all confirmation questions. Use with care!
387
388           If the --verify-passphrase option is not specified, this option
389           also switches off the passphrase verification.
390
391       --debug or --debug-json
392           Run in debug mode with full diagnostic logs. Debug output lines are
393           always prefixed by #.
394
395           If --debug-json is used, additional LUKS2 JSON data structures are
396           printed.
397
398       --version, -V
399           Show the program version.
400
401       --usage
402           Show short option help.
403
404       --help, -?
405           Show help text and default parameters.
406

REPORTING BUGS

408       Report bugs at cryptsetup mailing list <cryptsetup@lists.linux.dev> or
409       in Issues project section
410       <https://gitlab.com/cryptsetup/cryptsetup/-/issues/new>.
411
412       Please attach output of the failed command with --debug option added.
413

SEE ALSO

415       Cryptsetup FAQ
416       <https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions>
417
418       cryptsetup(8), integritysetup(8) and veritysetup(8)
419

CRYPTSETUP

421       Part of cryptsetup project <https://gitlab.com/cryptsetup/cryptsetup/>.
422
423
424
425cryptsetup 2.6.1                  2023-02-10          CRYPTSETUP-LUKSFORMAT(8)
Impressum