2014-08-24 18:18:18 +01:00
|
|
|
|
<chapter 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="ch-file-systems">
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<title>File Systems</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You can define file systems using the <option>fileSystems</option>
|
|
|
|
|
configuration option. For instance, the following definition causes NixOS to
|
|
|
|
|
mount the Ext4 file system on device
|
|
|
|
|
<filename>/dev/disk/by-label/data</filename> onto the mount point
|
|
|
|
|
<filename>/data</filename>:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-fileSystems"/>."/data" =
|
2014-08-24 18:18:18 +01:00
|
|
|
|
{ device = "/dev/disk/by-label/data";
|
|
|
|
|
fsType = "ext4";
|
|
|
|
|
};
|
|
|
|
|
</programlisting>
|
2020-05-14 17:00:01 +01:00
|
|
|
|
This will create an entry in <filename>/etc/fstab</filename>, 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>"noauto"</literal> is present in <link
|
2020-08-23 18:11:40 +01:00
|
|
|
|
linkend="opt-fileSystems._name_.options">options</link>.
|
2020-05-14 17:00:01 +01:00
|
|
|
|
<literal>"noauto"</literal> filesystems can be mounted explicitly using
|
|
|
|
|
<command>systemctl</command> e.g. <command>systemctl start
|
|
|
|
|
data.mount</command>.
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Mount points are created automatically if they don’t already exist. For
|
2020-08-23 18:11:40 +01:00
|
|
|
|
<option><link linkend="opt-fileSystems._name_.device">device</link></option>,
|
2019-09-19 18:17:30 +01:00
|
|
|
|
it’s best to use the topology-independent device aliases in
|
|
|
|
|
<filename>/dev/disk/by-label</filename> and
|
|
|
|
|
<filename>/dev/disk/by-uuid</filename>, as these don’t change if the
|
|
|
|
|
topology changes (e.g. if a disk is moved to another IDE controller).
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You can usually omit the file system type
|
2020-08-23 18:11:40 +01:00
|
|
|
|
(<option><link linkend="opt-fileSystems._name_.fsType">fsType</link></option>),
|
2019-09-19 18:17:30 +01:00
|
|
|
|
since <command>mount</command> 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 <option>fsType</option> to ensure that the kernel module is
|
|
|
|
|
available.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
<note>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
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
|
2020-08-23 18:11:40 +01:00
|
|
|
|
<literal><link linkend="opt-fileSystems._name_.options">options</link> = [
|
2019-09-19 18:17:30 +01:00
|
|
|
|
"nofail" ];</literal>.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
</note>
|
|
|
|
|
<xi:include href="luks-file-systems.xml" />
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</chapter>
|