Disko: Difference between revisions

From NixOS Wiki
imported>Onny
mNo edit summary
imported>Onny
mNo edit summary
Line 19: Line 19:
               name = "ESP";
               name = "ESP";
               start = "1MiB";
               start = "1MiB";
               end = "100MiB";
               end = "500MiB";
               bootable = true;
               bootable = true;
               content = {
               content = {
Line 29: Line 29:
             {
             {
               name = "root";
               name = "root";
               start = "100MiB";
               start = "500MiB";
               end = "100%";
               end = "100%";
               part-type = "primary";
               part-type = "primary";

Revision as of 15:46, 16 May 2023

Disko is a utility and NixOS module for declarative disk partitioning.

Usage

The following example creates a new GPT partition table for the disk /dev/vda including two partitions for EFI boot and a bcachefs root filesystem.

disko-config.nix
{ disks ? [ "/dev/vda" ], ... }: {
  disko.devices = {
    disk = {
      vdb = {
        device = builtins.elemAt disks 0;
        type = "disk";
        content = {
          type = "table";
          format = "gpt";
          partitions = [
            {
              name = "ESP";
              start = "1MiB";
              end = "500MiB";
              bootable = true;
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            }
            {
              name = "root";
              start = "500MiB";
              end = "100%";
              part-type = "primary";
              content = {
                type = "filesystem";
                format = "bcachefs";
                mountpoint = "/";
              };
            }
          ];
        };
      };
    };
  };
}

The following command will apply the disk layout specified in the configuration. Warning: This will erase all data on the disk.

# nix-env -iA nixos.disko
# sudo disko --mode zap_create_mount disko-config.nix