Filesystems: Difference between revisions

m Bind mounts: Drop stray quoted ref :/
DHCP (talk | contribs)
m use {{file}} template for configuration.nix
 
(5 intermediate revisions by 3 users not shown)
Line 5: Line 5:


Common example filesystem mount. You can put this in configuration.nix:
Common example filesystem mount. You can put this in configuration.nix:
<syntaxhighlight lang="nix">
{{file|configuration.nix|nix|3=
fileSystems."/mnt/exampleDrive" = {
fileSystems."/mnt/exampleDrive" = {
  device = "/dev/disk/by-uuid/4f999afe-6114-4531-ba37-4bf4a00efd9e";
  device = "/dev/disk/by-uuid/4f999afe-6114-4531-ba37-4bf4a00efd9e";
  fsType = "exfat";
  fsType = "exfat";
  options = [ # If you don't have this options attribute, it'll default to "defaults"  
  options = [ # If you don't have this options attribute, it'll default to "defaults"  
    # boot options for fstab. Search up fstab mount options you can use
    # boot options for fstab. Search up fstab mount options you can use
    "users" # Allows any user to mount and unmount
    "users" # Allows any user to mount and unmount
    "nofail" # Prevent system from failing if this drive doesn't mount
    "nofail" # Prevent system from failing if this drive doesn't mount
   
    "exec" # Permit execution of binaries and other executable files
  ];
  ];
};
};
</syntaxhighlight>
}}


== Making disk visible in your file explorer ==
== Making disk visible in your file explorer ==
Line 37: Line 37:


<blockquote>
<blockquote>
Bind mounting allows a filesystem hierarchy or a file to be mounted at a different mount point. Unlike a symbolic link, a bind mount does not exist on the filesystem itself. In the following example, the path {{ic|/olddir}} will be mounted in {{ic|/newdir}}
Bind mounting allows a filesystem hierarchy or a file to be mounted at a different mount point. Unlike a symbolic link, a bind mount does not exist on the filesystem itself.<ref>[https://en.wikipedia.org/wiki/Mount_(Unix)#Bind_mounting Wikipedia - Bind mount]</ref>
<ref>[https://en.wikipedia.org/wiki/Mount_(Unix)#Bind_mounting Wikipedia - Bind mount]</ref>
</blockquote>
</blockquote>


Line 65: Line 64:
};
};
</syntaxhighlight>
</syntaxhighlight>
== Tips and tricks ==
=== SSD TRIM support ===
On NixOS, [https://en.wikipedia.org/wiki/Trim_(computing) TRIM] support is enabled by default by the {{nixos:option|services.fstrim.enable}} option. This periodically discards unused blocks on supported storage devices, helping to maintain SSD performance over time.
The trimming schedule is controlled by the {{nixos:option|services.fstrim.interval}} option. Continuous trimming (as set by the <code>discard</code>, see <code>man mount(8)</code>) mount option is not recommended as it can negatively impact SSD performance.
Additionally, setting <code>noatime</code> can reduce the number of disk writes and can improve system performance.
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
fileSystems."/".options = [ "noatime" ];
</nowiki>
}}


= References =
= References =
<references />
<references />