Btrfs: Difference between revisions

imported>Vixea
Undo revision 8150 by Vixea (talk)
imported>Onny
Add section on subvolume snapshots
Line 1: Line 1:
'''btrfs''' is a modern copy on write (CoW) filesystem for Linux aimed at implementing advanced features while also focusing on fault tolerance, repair and easy administration.
'''btrfs''' is a modern copy on write (CoW) filesystem for Linux aimed at implementing advanced features while also focusing on fault tolerance, repair and easy administration.


== Installing NixOS on Btrfs ==
== Installation ==


{{note|The following example is for EFI enabled systems. Adjust commands accordingly for a BIOS installation.}}
{{note|The following example is for EFI enabled systems. Adjust commands accordingly for a BIOS installation.}}
Line 41: Line 41:
</syntaxhighlight>
</syntaxhighlight>


== Compression ==  
== Configuration ==
 
=== Compression == =


<code>nixos-generate-config --show-hardware-config</code> doesn't detect mount options automatically, so to enable compression, you must specify it and other mount options in a persistent configuration:
<code>nixos-generate-config --show-hardware-config</code> doesn't detect mount options automatically, so to enable compression, you must specify it and other mount options in a persistent configuration:
Line 54: Line 56:
</syntaxhighlight>
</syntaxhighlight>


== Swap file ==
=== Swap file ===


Optionally, create a separate subvolume for the swap file. Be sure to regenerate your <code>hardware-configuration.nix</code> if you choose to do this.
Optionally, create a separate subvolume for the swap file. Be sure to regenerate your <code>hardware-configuration.nix</code> if you choose to do this.
Line 80: Line 82:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
swapDevices = [ { device = "/swap/swapfile"; } ];
swapDevices = [ { device = "/swap/swapfile"; } ];
</syntaxhighlight>
== Usage ==
=== Snapshots ====
Taking a read-only (<code>-r</code>) snapshot called <code>nixos_snapshot_202302</code> of the subvolume mounted at <code>/</code>
<syntaxhighlight lang="bash">
btrfs subvolume snapshot -r / /mnt/@nixos_snapshot_202302
</syntaxhighlight>
List snapshots for <code>/</code>
<syntaxhighlight lang="bash">
sudo btrfs subvolume list /
</syntaxhighlight>
</syntaxhighlight>


[[Category: Configuration]]
[[Category: Configuration]]