summary refs log tree commit diff
path: root/nixos/doc/manual/from_md/configuration/file-systems.chapter.xml
blob: 71441d8b4a5b3f8b61ea9bee47efbcd85e0929df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ch-file-systems">
  <title>File Systems</title>
  <para>
    You can define file systems using the <literal>fileSystems</literal>
    configuration option. For instance, the following definition causes
    NixOS to mount the Ext4 file system on device
    <literal>/dev/disk/by-label/data</literal> onto the mount point
    <literal>/data</literal>:
  </para>
  <programlisting language="bash">
fileSystems.&quot;/data&quot; =
  { device = &quot;/dev/disk/by-label/data&quot;;
    fsType = &quot;ext4&quot;;
  };
</programlisting>
  <para>
    This will create an entry in <literal>/etc/fstab</literal>, which
    will generate a corresponding
    <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.mount.html">systemd.mount</link>
    unit via
    <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html">systemd-fstab-generator</link>.
    The filesystem will be mounted automatically unless
    <literal>&quot;noauto&quot;</literal> is present in
    <link linkend="opt-fileSystems._name_.options">options</link>.
    <literal>&quot;noauto&quot;</literal> filesystems can be mounted
    explicitly using <literal>systemctl</literal> e.g.
    <literal>systemctl start data.mount</literal>. Mount points are
    created automatically if they don’t already exist. For
    <literal>device</literal>, it’s best to use the topology-independent
    device aliases in <literal>/dev/disk/by-label</literal> and
    <literal>/dev/disk/by-uuid</literal>, as these don’t change if the
    topology changes (e.g. if a disk is moved to another IDE
    controller).
  </para>
  <para>
    You can usually omit the file system type
    (<literal>fsType</literal>), since <literal>mount</literal> can
    usually detect the type and load the necessary kernel module
    automatically. However, if the file system is needed at early boot
    (in the initial ramdisk) and is not <literal>ext2</literal>,
    <literal>ext3</literal> or <literal>ext4</literal>, then it’s best
    to specify <literal>fsType</literal> to ensure that the kernel
    module is available.
  </para>
  <note>
    <para>
      System startup will fail if any of the filesystems fails to mount,
      dropping you to the emergency shell. You can make a mount
      asynchronous and non-critical by adding
      <literal>options = [ &quot;nofail&quot; ];</literal>.
    </para>
  </note>
  <xi:include href="luks-file-systems.section.xml" />
  <xi:include href="sshfs-file-systems.section.xml" />
</chapter>