-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #806 from iFreilicht/luks-btrfs-raid-example
Luks btrfs raid example
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
pkgs ? import <nixpkgs> { }, | ||
diskoLib ? pkgs.callPackage ../lib { }, | ||
}: | ||
diskoLib.testLib.makeDiskoTest { | ||
inherit pkgs; | ||
name = "luks-btrfs-raid"; | ||
disko-config = ../example/luks-btrfs-raid.nix; | ||
extraTestScript = '' | ||
machine.succeed("cryptsetup isLuks /dev/vda2"); | ||
machine.succeed("cryptsetup isLuks /dev/vdb1"); | ||
machine.succeed("btrfs subvolume list /"); | ||
''; | ||
} |