2014-08-24 17:18:18 +00:00
|
|
|
<section xmlns="http://docbook.org/ns/docbook"
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
version="5.0"
|
|
|
|
xml:id="sec-luks-file-systems">
|
|
|
|
|
|
|
|
<title>LUKS-Encrypted File Systems</title>
|
|
|
|
|
|
|
|
<para>NixOS supports file systems that are encrypted using
|
|
|
|
<emphasis>LUKS</emphasis> (Linux Unified Key Setup). For example,
|
|
|
|
here is how you create an encrypted Ext4 file system on the device
|
2016-05-25 11:23:32 +00:00
|
|
|
<filename>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</filename>:
|
2014-08-24 17:18:18 +00:00
|
|
|
|
|
|
|
<screen>
|
2016-06-01 14:23:32 +00:00
|
|
|
# cryptsetup luksFormat /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d
|
2014-08-24 17:18:18 +00:00
|
|
|
|
|
|
|
WARNING!
|
|
|
|
========
|
2016-05-25 11:23:32 +00:00
|
|
|
This will overwrite data on /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d irrevocably.
|
2014-08-24 17:18:18 +00:00
|
|
|
|
|
|
|
Are you sure? (Type uppercase yes): YES
|
|
|
|
Enter LUKS passphrase: ***
|
|
|
|
Verify passphrase: ***
|
|
|
|
|
2016-06-01 14:23:32 +00:00
|
|
|
# cryptsetup luksOpen /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d crypted
|
2016-05-25 11:23:32 +00:00
|
|
|
Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
|
2014-08-24 17:18:18 +00:00
|
|
|
|
2016-06-01 14:23:32 +00:00
|
|
|
# mkfs.ext4 /dev/mapper/crypted
|
2014-08-24 17:18:18 +00:00
|
|
|
</screen>
|
|
|
|
|
|
|
|
To ensure that this file system is automatically mounted at boot time
|
|
|
|
as <filename>/</filename>, add the following to
|
|
|
|
<filename>configuration.nix</filename>:
|
|
|
|
|
|
|
|
<programlisting>
|
2016-05-25 11:23:32 +00:00
|
|
|
boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";
|
2014-08-24 17:18:18 +00:00
|
|
|
fileSystems."/".device = "/dev/mapper/crypted";
|
|
|
|
</programlisting>
|
|
|
|
|
2017-02-11 11:47:15 +00:00
|
|
|
Should grub be used as bootloader, and <filename>/boot</filename> is located
|
|
|
|
on an encrypted partition, it is necessary to add the following grub option:
|
|
|
|
<programlisting>boot.loader.grub.enableCryptodisk = true;</programlisting>
|
|
|
|
|
2014-08-24 17:18:18 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</section>
|