Fix and comment luks-encrypted btrfs raid example

This commit is contained in:
Felix Uhl committed 2024-10-01 19:35:27 +02:00
1 parent ba436edc9d
commit b9c99485aa
1 file changed
+59 -33
+59 -33
View File
@@ -1,49 +1,75 @@
{ {
disko.devices = { disko.devices = {
disk = { disk = {
disk0 = { # Devices will be mounted and formatted in alphabetical order, and btrfs can only mount raids
type = "disk"; # when all devices are present. So we define an "empty" luks device on the first disk,
device = "/dev/sdb"; # and the actual btrfs raid on the second disk, and the name of these entries matters!
content = {
type = "gpt";
partitions = {
crypted2 = {
name = "crypt_raidp2";
size = "100%";
content = {
type = "luks";
name = "raidp2"; # this is DM name
};
};
};
};
};
disk1 = { disk1 = {
type = "disk"; type = "disk";
device = "/dev/sda"; device = "/dev/sda";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
crypted1 = { ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
crypt_p1 = {
size = "100%"; size = "100%";
name = "crypt_raidp1";
content = { content = {
type = "luks"; type = "luks";
name = "raidp1"; name = "p1"; # device-mapper name when decrypted
content = { # Remove settings.keyFile if you want to use interactive password entry
type = "btrfs"; settings = {
extraArgs = [ "-f" "-m raid1 -d raid1" "/dev/mapper/raidp2"]; # raidp2 - DM name of 2nd disk allowDiscards = true;
keyFile = "/tmp/secret.key";
};
};
};
};
};
};
disk2 = {
type = "disk";
device = "/dev/sdb";
content = {
type = "gpt";
partitions = {
crypt_p2 = {
size = "100%";
content = {
type = "luks";
name = "p2";
# Remove settings.keyFile if you want to use interactive password entry
settings = {
allowDiscards = true;
keyFile = "/tmp/secret.key"; # Same key for both devices
};
content = {
type = "btrfs";
extraArgs = [
"-d raid1"
"/dev/mapper/p1" # Use decrypted mapped device, same name as defined in disk1
];
subvolumes = { subvolumes = {
"/" = { "/root" = {
mountpoint = "/mnt/SoftWare"; mountpoint = "/";
mountOptions = [ mountOptions = [
"rw" "relatime" "ssd" "discard=async" "space_cache=v2" "subvolid=5" "subvol=/" "rw"
]; "relatime"
}; "ssd"
}; ];
}; };
}; };
}; };
};
};
}; };
}; };
}; };