Bcachefs: Difference between revisions
→Usage: Change partition encryption password |
Console4852 (talk | contribs) github issue referenced in wiki is now fixed, so remove note. |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[https://bcachefs.org Bcachefs] is a next-generation CoW filesystem that aims to provide features from [[Btrfs]] and [[ZFS]] with a cleaner codebase, more stability, greater speed and a GPL-compatible license. It is built upon Bcache and is mainly developed by Kent Overstreet. | [https://bcachefs.org Bcachefs] is a next-generation CoW filesystem that aims to provide features from [[Btrfs]] and [[ZFS]] with a cleaner codebase<ref name=":0">citation needed</ref>, more stability<ref name=":0" />, greater speed<ref name=":0" /> and a GPL-compatible license. It is built upon Bcache and is mainly developed by Kent Overstreet. | ||
== Installation == | == Installation == | ||
Line 57: | Line 57: | ||
--label=hdd.hdd3 /dev/sde \ | --label=hdd.hdd3 /dev/sde \ | ||
--label=ssd.ssd1 /dev/sdf \ | --label=ssd.ssd1 /dev/sdf \ | ||
--label=ssd.ssd2 /dev/sdg | --label=ssd.ssd2 /dev/sdg \ | ||
--foreground_target=ssd \ | --foreground_target=ssd \ | ||
--promote_target=ssd \ | --promote_target=ssd \ | ||
Line 71: | Line 71: | ||
--label=hdd.hdd3 /dev/sde \ | --label=hdd.hdd3 /dev/sde \ | ||
--label=ssd.ssd1 /dev/sdf \ | --label=ssd.ssd1 /dev/sdf \ | ||
--label=ssd.ssd2 /dev/sdg | --label=ssd.ssd2 /dev/sdg \ | ||
--foreground_target=ssd \ | --foreground_target=ssd \ | ||
--promote_target=ssd \ | --promote_target=ssd \ | ||
Line 113: | Line 113: | ||
== Tips and tricks == | == Tips and tricks == | ||
=== 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 193: | Line 162: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
And using it like <code>UUID=<UUID></code> in place of <code>/dev/sda1:/dev/sdb1</code> or even just <code>/dev/sda</code>. | And using it like <code>UUID=<UUID></code> in place of <code>/dev/sda1:/dev/sdb1</code> or even just <code>/dev/sda</code>. | ||
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]. | ||
=== Remote encrypted disk unlocking === | === Remote encrypted disk unlocking === | ||
Line 213: | Line 173: | ||
after = [ "local-fs.target" ]; | after = [ "local-fs.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | wantedBy = [ "multi-user.target" ]; | ||
environment = { | |||
DEVICE_PATH = "/dev/sda1"; | |||
MOUNT_POINT = "/mnt"; | |||
}; | |||
script = '' | script = '' | ||
#!${pkgs.runtimeShell} -e | #!${pkgs.runtimeShell} -e | ||
${pkgs.keyutils}/bin/keyctl link @u @s | ${pkgs.keyutils}/bin/keyctl link @u @s | ||
echo "Waiting for | # Check if the device path exists | ||
if [ ! -b "$DEVICE_PATH" ]; then | |||
echo "Error: Device path $DEVICE_PATH does not exist." | |||
exit 1 | |||
fi | |||
# Check if the drive is already mounted | |||
if ${pkgs.util-linux}/bin/mountpoint -q "$MOUNT_POINT"; then | |||
echo "Drive already mounted at $MOUNT_POINT. Skipping..." | |||
exit 0 | |||
fi | |||
# Wait for the device to become available | |||
while [ ! -b "$DEVICE_PATH" ]; do | |||
echo "Waiting for $DEVICE_PATH to become available..." | |||
sleep 5 | sleep 5 | ||
done | done | ||
${pkgs.bcachefs-tools}/bin/bcachefs mount -f /etc/keyfile_test | |||
# Mount the device | |||
${pkgs.bcachefs-tools}/bin/bcachefs mount -f /etc/keyfile_test "$DEVICE_PATH" "$MOUNT_POINT" | |||
''; | ''; | ||
serviceConfig = { | serviceConfig = { |