File tree Expand file tree Collapse file tree 5 files changed +136
-8
lines changed Expand file tree Collapse file tree 5 files changed +136
-8
lines changed Original file line number Diff line number Diff line change 1+ {
2+ disko . devices . disk = {
3+ one = {
4+ type = "disk" ;
5+ device = "/dev/vda" ;
6+
7+ content = {
8+ type = "gpt" ;
9+
10+ partitions = {
11+ boot = {
12+ size = "1M" ;
13+ type = "EF02" ;
14+ } ;
15+
16+ esp = {
17+ size = "1G" ;
18+ type = "EF00" ;
19+
20+ content = {
21+ type = "filesystem" ;
22+ format = "vfat" ;
23+ mountpoint = "/boot0" ;
24+ mountOptions = [ "umask=0077" ] ;
25+ } ;
26+ } ;
27+
28+ root = {
29+ size = "100%" ;
30+
31+ content = {
32+ type = "btrfs" ;
33+ } ;
34+ } ;
35+ } ;
36+ } ;
37+ } ;
38+
39+ two = {
40+ type = "disk" ;
41+ device = "/dev/vdb" ;
42+
43+ content = {
44+ type = "gpt" ;
45+
46+ partitions = {
47+ boot = {
48+ size = "1M" ;
49+ type = "EF02" ;
50+ } ;
51+
52+ esp = {
53+ size = "1G" ;
54+ type = "EF00" ;
55+
56+ content = {
57+ type = "filesystem" ;
58+ format = "vfat" ;
59+ mountpoint = "/boot1" ;
60+ mountOptions = [ "umask=0077" ] ;
61+ } ;
62+ } ;
63+
64+ root = {
65+ size = "100%" ;
66+
67+ content = {
68+ type = "btrfs" ;
69+ mountpoint = "/" ;
70+ extraArgs = [
71+ "-f"
72+ "-d raid1"
73+ "/dev/disk/by-partlabel/disk-one-root"
74+ ] ;
75+ } ;
76+ } ;
77+ } ;
78+ } ;
79+ } ;
80+ } ;
81+ }
Original file line number Diff line number Diff line change @@ -1059,13 +1059,40 @@ let
10591059 '' ;
10601060 default =
10611061 with lib ;
1062- let
1063- configKeys = flatten (
1064- map attrNames ( flatten ( map ( dev : dev . _config ) ( flatten ( map attrValues ( attrValues devices ) ) ) ) )
1065- ) ;
1066- collectedConfigs = flatten ( map ( dev : dev . _config ) ( flatten ( map attrValues ( attrValues devices ) ) ) ) ;
1067- in
1068- genAttrs configKeys ( key : mkMerge ( catAttrs key collectedConfigs ) ) ;
1062+ (
1063+ let
1064+ configKeys = flatten (
1065+ map attrNames ( flatten ( map ( dev : dev . _config ) ( flatten ( map attrValues ( attrValues devices ) ) ) ) )
1066+ ) ;
1067+ collectedConfigs = flatten ( map ( dev : dev . _config ) ( flatten ( map attrValues ( attrValues devices ) ) ) ) ;
1068+ in
1069+ genAttrs configKeys ( key : mkMerge ( catAttrs key collectedConfigs ) )
1070+ )
1071+ // (
1072+ let
1073+ efi_partitions = builtins . filter ( part : part . type == "EF00" ) (
1074+ flatten (
1075+ map (
1076+ disk :
1077+ map ( part : part // { device = disk . device ; } ) (
1078+ if builtins . hasAttr "content" disk then attrValues disk . content . partitions else [ ]
1079+ )
1080+ ) ( flatten ( map attrValues ( attrValues devices ) ) )
1081+ )
1082+ ) ;
1083+ in
1084+ ( optionalAttrs ( builtins . length efi_partitions >= 2 ) {
1085+ # Mirrored boot partitions are not supported on systemd-boot.
1086+ boot . loader . grub . enable = mkForce true ;
1087+ boot . loader . grub . devices = mkForce [ ] ;
1088+ boot . loader . grub . mirroredBoots = mkForce (
1089+ map ( part : {
1090+ devices = [ part . device ] ;
1091+ path = part . content . mountpoint ;
1092+ } ) efi_partitions
1093+ ) ;
1094+ } )
1095+ ) ;
10691096 } ;
10701097 } ;
10711098 }
Original file line number Diff line number Diff line change 6464 disko . testMode = true ;
6565 disko . devices = lib . mkForce cleanedConfig . disko . devices ;
6666 boot . loader . grub . devices = lib . mkForce cleanedConfig . boot . loader . grub . devices ;
67+ boot . loader . grub . mirroredBoots = lib . mkForce cleanedConfig . boot . loader . grub . mirroredBoots ;
6768 }
6869 ] ;
6970 } ;
7778 disko . devices = lib . mkForce cleanedConfig . disko . devices ;
7879 boot . loader . grub . devices = lib . mkForce cleanedConfig . boot . loader . grub . devices ;
7980 boot . kernelPackages = cfg . kernelPackages ;
81+ boot . loader . grub . mirroredBoots = lib . mkForce cleanedConfig . boot . loader . grub . mirroredBoots ;
8082 nixpkgs . hostPlatform = lib . mkForce pkgs . stdenv . hostPlatform ;
8183 nixpkgs . buildPlatform = lib . mkForce pkgs . stdenv . hostPlatform ;
8284 }
Original file line number Diff line number Diff line change 185185 boot . swraid . mdadmConf = "PROGRAM ${ pkgs . coreutils } /bin/true" ;
186186
187187 # grub will install to these devices, we need to force those or we are offset by 1
188- # we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
188+ # we use mkOverride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
189189 boot . loader . grub . devices = lib . mkOverride 70 testConfigInstall . boot . loader . grub . devices ;
190190
191191 assertions = [
Original file line number Diff line number Diff line change 1+ {
2+ pkgs ? import <nixpkgs> { } ,
3+ diskoLib ? pkgs . callPackage ../lib { } ,
4+ } :
5+ diskoLib . testLib . makeDiskoTest {
6+ inherit pkgs ;
7+ name = "btrfs-raid-mirrored-boot" ;
8+ disko-config = ../example/btrfs-raid-mirrored-boot.nix ;
9+ extraTestScript = ''
10+ machine.succeed("mountpoint /");
11+ machine.succeed("mountpoint /boot0");
12+ machine.succeed("mountpoint /boot1");
13+ '' ;
14+ extraSystemConfig = {
15+ # Mirrored boot partitions are not supported on systemd-boot.
16+ boot . loader . systemd-boot . enable = false ;
17+ } ;
18+ }
You can’t perform that action at this time.
0 commit comments