Skip to content

Commit

Permalink
Fix the zfs partitions
Browse files Browse the repository at this point in the history
Remove unneeded partitions
Add compression
Add swap space
- enable encrypted swap
- enable resume from the swap partition

Signed-off-by: Brian McGillion <[email protected]>
  • Loading branch information
brianmcgillion committed Oct 21, 2024
1 parent ea98844 commit 7330d67
Showing 1 changed file with 19 additions and 48 deletions.
67 changes: 19 additions & 48 deletions modules/disko/disko-ab-partitions.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
# This partition scheme contains three common partitions and ZFS pool.
# Some partitions are duplicated for the future AB SWupdate implementation.
#
# First three partitions are related to the boot process:
# First two partitions are related to the boot process:
# - boot : Bootloader partition
# - ESP-A : (500M) Kernel and initrd
# - ESP-B : (500M)
#
# ZFS datasets do not necessary need to have specified size and can be
# allocated dynamically. Quotas only restrict the maximum size of
# datasets, but do not reserve the space in the pool.
# The ZFS pool contains next datasets:
# - root-A : (30G) Root FS
# - root-B : (30G)
# - vm-storage-A : (30G) Possible standalone pre-built VM images are stored here
# - vm-storage-B : (30G)
# - reserved-A : (10G) Reserved dataset, no use
# - reserved-B : (10G)
# - root : (30G) Root FS
# - vm-storage : (30G) Possible standalone pre-built VM images are stored here
# - reserved : (10G) Reserved dataset, no use
# - gp-storage : (50G) General purpose storage for some common insecure cases
# - recovery : (no quota) Recovery factory image is stored here
# - storagevm: (no quota) Dataset is meant to be used for StorageVM
Expand All @@ -34,7 +30,7 @@
};
disko = {
# 8GB is the recommeneded minimum for ZFS, so we are using this for VMs to avoid `cp` oom errors.
memSize = 16384;
memSize = 17384;
imageBuilder = {
extraPostVM = ''
${pkgs.zstd}/bin/zstd --compress $out/*raw
Expand All @@ -44,7 +40,7 @@
devices = {
disk.disk1 = {
type = "disk";
imageSize = "15G";
imageSize = "60G";
content = {
type = "gpt";
partitions = {
Expand All @@ -54,8 +50,8 @@
type = "EF02";
priority = 1; # Needs to be first partition
};
esp_a = {
name = "ESP_A";
esp = {
name = "ESP";
size = "500M";
type = "EF00";
content = {
Expand All @@ -68,17 +64,14 @@
];
};
};
esp_b = {
name = "ESP_B";
size = "500M";
type = "EF00";
swap = {
size = "38G";
type = "8200";
content = {
type = "filesystem";
format = "vfat";
mountOptions = [
"umask=0077"
"nofail"
];
type = "swap";
resumeDevice = true; # resume from hiberation from this device
# TODO: remove when LUKS is enabled
#randomEncryption = true;
};
};
zfs_1 = {
Expand All @@ -97,6 +90,7 @@
rootFsOptions = {
mountpoint = "none";
acltype = "posixacl";
compression = "lz4";
xattr = "sa";
};
# `ashift=12` optimizes alignment for 4K sector size.
Expand All @@ -105,43 +99,22 @@
# This trades off some space overhead for overall better performance on 4k devices.
options.ashift = "12";
datasets = {
"root_a" = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
options = {
mountpoint = "/";
quota = "30G";
};
};
"vm_storage_a" = {
"vm_storage" = {
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 = "30G";
};
};
"vm_storage_b" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "30G";
};
};
"reserved_b" = {
"reserved" = {
type = "zfs_fs";
options = {
mountpoint = "none";
Expand All @@ -165,8 +138,6 @@
type = "zfs_fs";
options = {
mountpoint = "/storagevm";
acltype = "posixacl";
xattr = "sa";
};
};
};
Expand Down

0 comments on commit 7330d67

Please sign in to comment.