Skip to content

Commit

Permalink
Add ZFS config for disko
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com>
  • Loading branch information
unbel13ver committed May 15, 2024
1 parent 8bbf2c9 commit ac41cca
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 3 deletions.
161 changes: 161 additions & 0 deletions modules/disko/disko-ab-partitions-zfs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
# !!! To utilize this partition scheme, the disk size must be >252G !!!
#
# This partition scheme contains three common partitions and two ZFS pools.
# First LVM pool occupies 250G and second one occupies the rest of the disk space.
# Some paritions are duplicated for the future AB SWupdate implementation.
#
# First three partitions are related to the boot process:
# - boot : Bootloader partition
# - ESP-A : (500M) Kernel and initrd
# - ESP-B : (500M)
#
# First ZFS pool contains next partitions:
# - root-A : (50G) Root FS
# - root-B : (50G)
# - vm-storage-A : (30G) Possible standalone pre-built VM images are stored here
# - vm-storage-B : (30G)
# - reserved-A : (10G) Reserved partition, no use
# - reserved-B : (10G)
# - gp-storage : (50G) General purpose storage for some common insecure cases
# - recovery : (rest of the LVM pool) Recovery factory image is stored here
#
# Second ZFS pool is dedicated for Storage VM completely.
_: {
networking.hostId = "8425e349";
# A lot of memory required for some unknown reason
disko.memSize = 16000;
disko.extraRootModules = ["zfs"];
disko.devices = {
disk.disk1 = {
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp_a = {
name = "ESP_A";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"umask=0077"
"nofail"
];
};
};
esp_b = {
name = "ESP_B";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountOptions = [
"umask=0077"
"nofail"
];
};
};
zfs_1 = {
size = "250G";
content = {
type = "zfs";
pool = "zroot_1";
};
};
# ZFS pool that is going to be passed to the Storage VM
zfs_2 = {
content = {
type = "zfs";
pool = "zroot_2";
};
};
};
};
};
zpool = {
zroot_1 = {
type = "zpool";
rootFsOptions = {
mountpoint = "none";
};
datasets = {
"root_a" = {
type = "zfs_fs";
mountpoint = "/";
options = {
mountpoint = "/";
quota = "50G";
};
};
"vm_storage_a" = {
type = "zfs_fs";
options = {
mountpoint = "/vm_storage";
quota = "30G";
};
};
"reserved_a" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "10G";
};
};
"root_b" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "50G";
};
};
"vm_storage_b" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "30G";
};
};
"reserved_b" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "10G";
};
};
"gp_storage" = {
type = "zfs_fs";
options = {
mountpoint = "/gp_storage";
quota = "50G";
};
};
"recovery" = {
type = "zfs_fs";
options = {
mountpoint = "none";
};
};
};
};
zroot_2 = {
# Dedicated partition for StorageVM
type = "zpool";
mountpoint = "/storagevm";
rootFsOptions = {
canmount = "off";
};
};
};
};
}
2 changes: 1 addition & 1 deletion modules/disko/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

disko-ab-partitions-v1.imports = [
inputs.disko.nixosModules.disko
./disko-ab-partitions.nix
./disko-ab-partitions-zfs.nix
./disko-basic-postboot.nix
];
};
Expand Down
6 changes: 4 additions & 2 deletions modules/hardware/lenovo-x1/definitions/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ in {
ghaf.hardware.definition = {
inherit (hwDefinition) mouse;
inherit (hwDefinition) touchpad;
inherit (hwDefinition) disks;
inherit (hwDefinition) network;
inherit (hwDefinition) gpu;

Expand All @@ -37,7 +36,10 @@ in {
];
};

disko.devices.disk = hwDefinition.disks;
disko.devices.disk = {
disk1.device = "/dev/nvme0n1";
disk1.imageSize = "260G";
};

# Notes:
# 1. This assembles udev rules for different hw configurations (i.e., different mice/touchpads) by adding
Expand Down

0 comments on commit ac41cca

Please sign in to comment.