-
-
Notifications
You must be signed in to change notification settings - Fork 199
/
luks-btrfs-raid.nix
78 lines (78 loc) · 2.34 KB
/
luks-btrfs-raid.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
disko.devices = {
disk = {
# Devices will be mounted and formatted in alphabetical order, and btrfs can only mount raids
# when all devices are present. So we define an "empty" luks device on the first disk,
# and the actual btrfs raid on the second disk, and the name of these entries matters!
disk1 = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
crypt_p1 = {
size = "100%";
content = {
type = "luks";
name = "p1"; # device-mapper name when decrypted
# Remove settings.keyFile if you want to use interactive password entry
settings = {
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 = {
"/root" = {
mountpoint = "/";
mountOptions = [
"rw"
"relatime"
"ssd"
];
};
};
};
};
};
};
};
};
};
};
}