1<chapter xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
4 version="5.0"
5 xml:id="ch-file-systems">
6 <title>File Systems</title>
7 <para>
8 You can define file systems using the <option>fileSystems</option>
9 configuration option. For instance, the following definition causes NixOS to
10 mount the Ext4 file system on device
11 <filename>/dev/disk/by-label/data</filename> onto the mount point
12 <filename>/data</filename>:
13<programlisting>
14<xref linkend="opt-fileSystems"/>."/data" =
15 { device = "/dev/disk/by-label/data";
16 fsType = "ext4";
17 };
18</programlisting>
19 Mount points are created automatically if they don’t already exist. For
20 <option><link linkend="opt-fileSystems._name__.device">device</link></option>,
21 it’s best to use the topology-independent device aliases in
22 <filename>/dev/disk/by-label</filename> and
23 <filename>/dev/disk/by-uuid</filename>, as these don’t change if the
24 topology changes (e.g. if a disk is moved to another IDE controller).
25 </para>
26 <para>
27 You can usually omit the file system type
28 (<option><link linkend="opt-fileSystems._name__.fsType">fsType</link></option>),
29 since <command>mount</command> can usually detect the type and load the
30 necessary kernel module automatically. However, if the file system is needed
31 at early boot (in the initial ramdisk) and is not <literal>ext2</literal>,
32 <literal>ext3</literal> or <literal>ext4</literal>, then it’s best to
33 specify <option>fsType</option> to ensure that the kernel module is
34 available.
35 </para>
36 <note>
37 <para>
38 System startup will fail if any of the filesystems fails to mount, dropping
39 you to the emergency shell. You can make a mount asynchronous and
40 non-critical by adding
41 <literal><link linkend="opt-fileSystems._name__.options">options</link> = [
42 "nofail" ];</literal>.
43 </para>
44 </note>
45 <xi:include href="luks-file-systems.xml" />
46</chapter>