Bcachefs: Difference between revisions

m Citation needed. Especially regarding stability compared to ZFS
Onny (talk | contribs)
Update page for NixOS 25.05. Release contains a kernel with bcachefs now
Line 113: Line 113:


== Tips and tricks ==
== Tips and tricks ==
=== Generate bcachefs enabled installation media ===
Use following Nix [[Flakes|Flake-expression]] to generate a ISO installation image with a bcachefs enabled kernel
{{file|flake.nix|nix|<nowiki>
{
  description = "Bcachefs enabled installation media";
  inputs.nixos.url = "nixpkgs/nixos-24.11";
  outputs = { self, nixos }: {
    nixosConfigurations = {
      exampleIso = nixos.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          "${nixos}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix"
          ({ lib, pkgs, ... }: {
            # Might be required as a workaround for bug
            # https://github.com/NixOS/nixpkgs/issues/32279
            environment.systemPackages = [ pkgs.keyutils ];
            boot.supportedFilesystems = [ "bcachefs" ];
          })
        ];
      };
    };
  };
}
</nowiki>}}
The following commands will generate the iso-image which will be available in the directory <code>./result/iso</code>
<syntaxhighlight lang="console">
# nix build .#nixosConfigurations.exampleIso.config.system.build.isoImage
</syntaxhighlight>


=== NixOS installation on bcachefs ===
=== NixOS installation on bcachefs ===
Line 166: Line 133:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# mkfs.fat -F 32 -n boot /dev/sda1
# mkfs.fat -F 32 -n boot /dev/sda1
# nix shell -p bcachefs-tools
# mkfs.bcachefs -L nixos /dev/sda2
# mkfs.bcachefs -L nixos /dev/sda2
</syntaxhighlight>
</syntaxhighlight>
Line 173: Line 141:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# nix-shell -p keyutils --run 'keyctl link @u @s'
# nix-shell -p keyutils --run 'keyctl link @u @s'
# nix-shell -p bcachefs-tools
# bcachefs format --encrypted /dev/sda2
# bcachefs format --encrypted /dev/sda2
# bcachefs unlock /dev/sda2
# bcachefs unlock /dev/sda2
Line 197: Line 166:


Continue installation as recommended by the [https://nixos.org/manual/nixos/stable/index.html#ch-installation NixOS manual].
Continue installation as recommended by the [https://nixos.org/manual/nixos/stable/index.html#ch-installation NixOS manual].
Before <code>nixos-install</code> you'll have to adapt the generated NixOS configuration to also use the latest Linux kernel supporting Bcachefs. Add the following line to the <code>configuration.nix</code> in your installation root (/mnt):
{{file|/mnt/etc/nixos/configuration.nix|nix|<nowiki>
boot.supportedFilesystems = [ "bcachefs" ];
boot.kernelPackages = pkgs.linuxPackages_latest;
</nowiki>}}


=== Remote encrypted disk unlocking ===
=== Remote encrypted disk unlocking ===