Skip to content

Latest commit

 

History

History
87 lines (81 loc) · 2.08 KB

disk_config.nix.md

File metadata and controls

87 lines (81 loc) · 2.08 KB

Sample disk_config Configuration

This is a sample of a simple disk_config file to specify file system partitioning configurations for use with nixos-remote.

Partitioning is carried out by the disko utility. More examples of disk configurations are available here. You can browse through these to find a configuration that is suitable for your server.

Copy the configuration into a file named disk_config.nix. This should be in the same location as flake.nix.

# Example to create a bios compatible GPT partition
{ lib, disks ? [ "/dev/sda" ], ... }: {
  disk = lib.genAttrs disks (dev: {
    device = dev;
    type = "disk";
    content = {
      type = "table";
      format = "gpt";
      partitions = [
        {
          name = "boot";
          type = "partition";
          start = "0";
          end = "1M";
          part-type = "primary";
          flags = ["bios_grub"];
        }
        {
          type = "partition";
          name = "ESP";
          start = "1MiB";
          end = "100MiB";
          bootable = true;
          content = {
            type = "mdraid";
            name = "boot";
          };
        }
        {
          name = "root";
          type = "partition";
          start = "100MiB";
          end = "100%";
          part-type = "primary";
          bootable = true;
          content = {
            type = "lvm_pv";
            vg = "pool";
          };
        }
      ];
    };
  });
  mdadm = {
    boot = {
      type = "mdadm";
      level = 1;
      metadata = "1.0";
      content = {
        type = "filesystem";
        format = "vfat";
        mountpoint = "/boot";
      };
    };
  };
  lvm_vg = {
    pool = {
      type = "lvm_vg";
      lvs = {
        root = {
          type = "lvm_lv";
          size = "100%FREE";
          content = {
            type = "filesystem";
            format = "ext4";
            mountpoint = "/";
            mountOptions = [
              "defaults"
            ];
          };
        };
      };
    };
  };
}