mirror of
https://github.com/nix-community/disko.git
synced 2026-01-15 02:38:48 +01:00
bcachefs: fix subvolume mounting
This commit is contained in:
parent
7c1879bd85
commit
1e95379d79
3 changed files with 45 additions and 33 deletions
|
|
@ -135,13 +135,6 @@
|
|||
relies_on_external_subvolume = {
|
||||
type = "bcachefs_filesystem";
|
||||
mountpoint = "/home/Documents";
|
||||
extraFormatArgs = [
|
||||
"--compression=lz4"
|
||||
"--background_compression=lz4"
|
||||
];
|
||||
mountOptions = [
|
||||
"verbose"
|
||||
];
|
||||
uuid = "64e50034-ebe2-eaf8-1f93-cf56266a8d86";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -194,9 +194,10 @@
|
|||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
bcachefs mount \
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||
UUID="${config.uuid}" \
|
||||
"/dev/disk/by-uuid/${config.uuid}" \
|
||||
"$MNTPOINT";
|
||||
trap 'umount "$MNTPOINT"; rm -rf "$MNTPOINT"; rm -rf "$TEMPDIR";' EXIT;
|
||||
SUBVOL_ABS_PATH="$MNTPOINT/${subvolume.name}";
|
||||
|
|
@ -230,7 +231,8 @@
|
|||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
bcachefs mount \
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${
|
||||
lib.concatStringsSep "," (
|
||||
lib.unique (
|
||||
|
|
@ -242,7 +244,7 @@
|
|||
)
|
||||
)
|
||||
}" \
|
||||
UUID="${config.uuid}" \
|
||||
"/dev/disk/by-uuid/${config.uuid}" \
|
||||
"${rootMountPoint}${subvolume.mountpoint}";
|
||||
fi;
|
||||
'';
|
||||
|
|
@ -261,9 +263,10 @@
|
|||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
bcachefs mount \
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||
UUID="${config.uuid}" \
|
||||
"/dev/disk/by-uuid/${config.uuid}" \
|
||||
"${rootMountPoint}${config.mountpoint}";
|
||||
fi;
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -15,14 +15,27 @@ diskoLib.testLib.makeDiskoTest {
|
|||
machine.wait_for_text("enter passphrase for /nix");
|
||||
machine.send_chars("secretsecret\n");
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_testing;
|
||||
supportedFilesystems = [ "bcachefs" ];
|
||||
};
|
||||
};
|
||||
extraSystemConfig = {
|
||||
environment.systemPackages = [
|
||||
pkgs.jq
|
||||
];
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
# Copy tools for bcachefs
|
||||
copy_bin_and_libs ${pkgs.lib.getOutput "mount" pkgs.util-linux}/bin/mount
|
||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
|
||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs
|
||||
'';
|
||||
};
|
||||
extraTestScript = ''
|
||||
# Print debug information.
|
||||
machine.succeed("ls -la /subvolumes >&2");
|
||||
machine.succeed("uname -a >&2");
|
||||
machine.succeed("ls -la / >&2");
|
||||
machine.succeed("lsblk >&2");
|
||||
machine.succeed("lsblk -f >&2");
|
||||
machine.succeed("mount >&2");
|
||||
|
|
@ -30,14 +43,6 @@ diskoLib.testLib.makeDiskoTest {
|
|||
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||
machine.succeed("findmnt --json >&2");
|
||||
|
||||
# Verify subvolume structure.
|
||||
machine.succeed("test -d /subvolumes/root");
|
||||
machine.succeed("test -d /subvolumes/home");
|
||||
machine.succeed("test -d /subvolumes/home/user");
|
||||
machine.succeed("test -d /subvolumes/nix");
|
||||
machine.succeed("test -d /subvolumes/test");
|
||||
machine.fail("test -d /subvolumes/non-existent");
|
||||
|
||||
# Verify existence of mountpoints.
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /home");
|
||||
|
|
@ -48,15 +53,21 @@ diskoLib.testLib.makeDiskoTest {
|
|||
# Verify device membership and labels.
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]+Label:[[:space:]]+vdb2[[:space:]]\([[:digit:]]+\)'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]+Label:[[:space:]]+vdc1[[:space:]]\([[:digit:]]+\)'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]+Label:[[:space:]]+vdd1[[:space:]]\([[:digit:]]+\)'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]+Label:[[:space:]]+vde1[[:space:]]\([[:digit:]]+\)'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
||||
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
||||
|
||||
# @todo Verify format arguments.
|
||||
# Verify format arguments.
|
||||
# Test that lza4 compression and background_compression options were set for vda2.
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
|
||||
# Test that no compression option was set for vdd1.
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
|
||||
|
||||
# Verify mount options from configuration.
|
||||
# Test that verbose option was set for "/".
|
||||
machine.succeed("""
|
||||
findmnt --json \
|
||||
| jq -e ' \
|
||||
|
|
@ -64,11 +75,12 @@ diskoLib.testLib.makeDiskoTest {
|
|||
| select(.target == "/") \
|
||||
| .options \
|
||||
| split(",") \
|
||||
| contains(["verbose", "compression=lz4", "background_compression=lz4"]) \
|
||||
| contains(["verbose"]) \
|
||||
'
|
||||
""");
|
||||
|
||||
machine.succeed("""
|
||||
# Test that verbose option was not set for "/home/Documents".
|
||||
machine.fail("""
|
||||
findmnt --json \
|
||||
| jq -e ' \
|
||||
.filesystems[] \
|
||||
|
|
@ -80,6 +92,7 @@ diskoLib.testLib.makeDiskoTest {
|
|||
'
|
||||
""");
|
||||
|
||||
# Test that non-existent option was not set for "/".
|
||||
machine.fail("""
|
||||
findmnt --json \
|
||||
| jq -e ' \
|
||||
|
|
@ -97,8 +110,11 @@ diskoLib.testLib.makeDiskoTest {
|
|||
| jq -e ' \
|
||||
.filesystems[] \
|
||||
| select(.target == "/") \
|
||||
| .source | split(":") \
|
||||
| contains(["/dev/vda2", "/dev/vdb1", "/dev/vdc1"]) \
|
||||
| .source \
|
||||
| contains("/dev/vda2") \
|
||||
and contains("/dev/vdb1") \
|
||||
and contains("/dev/vdc1") \
|
||||
and contains("[/subvolumes/root]") \
|
||||
'
|
||||
""");
|
||||
|
||||
|
|
@ -109,7 +125,7 @@ diskoLib.testLib.makeDiskoTest {
|
|||
| .. \
|
||||
| select(.target? == "/home/Documents") \
|
||||
| .source \
|
||||
| contains("/dev/disk/by-uuid/64e50034-ebe2-eaf8-1f93-cf56266a8d86") \
|
||||
| contains("/dev/vdd1") \
|
||||
'
|
||||
""");
|
||||
|
||||
|
|
@ -118,7 +134,7 @@ diskoLib.testLib.makeDiskoTest {
|
|||
| jq -e ' \
|
||||
.filesystems[] \
|
||||
| select(.target == "/") \
|
||||
| .source | split(":") \
|
||||
| .source \
|
||||
| contains(["/dev/non-existent"]) \
|
||||
'
|
||||
""");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue