Btrfs: Difference between revisions

imported>Raboof
Format partitions and create subvolumes: document you need btrfs-progs for mkfs.btrfs
imported>Ryan4yin
restore root subvolume via boot.initrd.postDeviceCommands
Line 221: Line 221:
# Take an empty *readonly* snapshot of the root subvolume, which can be rollback to on every boot.
# Take an empty *readonly* snapshot of the root subvolume, which can be rollback to on every boot.
btrfs subvolume snapshot -r /mnt/root /mnt/root-blank
btrfs subvolume snapshot -r /mnt/root /mnt/root-blank
</syntaxhighlight>
Add the following nix config to clear the root volume on every boot([https://grahamc.com/blog/erase-your-darlings/ Erase your darlings]):
<syntaxhighlight lang="nix">
{
  boot.initrd.postDeviceCommands = lib.mkAfter ''
    mkdir /mnt
    mount -t btrfs /dev/mapper/enc /mnt
    btrfs subvolume delete /mnt/root
    btrfs subvolume snapshot /mnt/root-blank /mnt/root
  '';
}
</syntaxhighlight>
</syntaxhighlight>