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