2
0
Fork 0
mirror of https://github.com/nix-community/disko synced 2025-02-03 06:33:26 +00:00
No description
Find a file
github-actions[bot] 18d0a984cc flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/8c9fd3e564728e90829ee7dbac6edc972971cd0f?narHash=sha256-CHd7yhaDigUuJyDeX0SADbTM9FXfiWaeNyY34FL1wQU%3D' (2025-01-07)
  → 'github:NixOS/nixpkgs/5d3221fd57cc442a1a522a15eb5f58230f45a304?narHash=sha256-H%2BFXIKj//kmFHTTW4DFeOjR7F1z2/3eb2iwN6Me4YZk%3D' (2025-01-26)
2025-01-29 10:53:55 +00:00
.github build(deps): bump cachix/install-nix-action from 29 to 30 2024-10-07 20:52:56 +00:00
disk-deactivate disk-deactivate: also clear zpool labels 2024-09-03 17:10:47 +02:00
docs Fix minor typo 2025-01-12 20:29:17 +01:00
example zfs_volume: add zfs_volume without content to zfs example 2025-01-16 14:45:30 +01:00
lib zfs_volume: fix eval of _unmount if content is null 2025-01-16 14:46:04 +01:00
scripts release: fix wrong push command 2024-10-12 00:49:30 +02:00
tests doc: simple xfs with options 2024-12-28 16:43:16 -05:00
.gitignore docs: Add docs for contributors 2024-10-16 17:27:36 +00:00
.mergify.yml Fix mergify deprecation warning 2024-10-11 11:13:39 +02:00
cli.nix cli: remove traceValSeq that shouldn't be there 2024-12-20 14:24:53 +01:00
CONTRIBUTING.md docs: Add docs for contributors 2024-10-16 17:27:36 +00:00
default.nix add unmount feature 2024-11-29 14:44:15 +01:00
disko add unmount feature 2024-11-29 14:44:15 +01:00
disko-install check for db.sqlite rather than /nix/store 2024-12-05 13:05:22 +01:00
doc.nix lib: refactor outputs into toplevel 2023-07-19 19:07:40 +00:00
flake.lock flake.lock: Update 2025-01-29 10:53:55 +00:00
flake.nix export nixosModule as file 2025-01-09 14:17:26 +01:00
install-cli.nix install-cli: use disks from diskMappings arg for grub devices 2025-01-10 17:17:54 +01:00
LICENSE List all copyright years 2024-02-15 20:31:41 +00:00
module.nix disko: fix postVM beeing empty 2025-01-11 09:56:21 +00:00
package.nix disko cli: add --version command 2024-10-11 15:14:56 +00:00
README.md fix: Apply umask=0077 to /boot partition in all examples 2025-01-06 20:23:33 +01:00
statix.toml style: Disable inherit pattern check in statix 2023-02-07 15:37:12 +00:00
version.nix release: reset released flag 2024-12-13 12:09:27 +01:00

disko - Declarative disk partitioning

Project logo

Documentation Index

NixOS is a Linux distribution where everything is described as code, with one exception: during installation, the disk partitioning and formatting are manual steps. disko aims to correct this sad 🤡 omission.

This is especially useful for unattended installations, re-installation after a system crash or for setting up more than one identical server.

Overview

disko can either be used after booting from a NixOS installer, or in conjunction with nixos-anywhere if you're installing remotely.

Before using disko, the specifications of the disks, partitions, type of formatting and the mount points must be defined in a Nix configuration. You can find examples of typical configurations in the Nix community repository, and use one of these as the basis of your own configuration.

You can keep your configuration and re-use it for other installations, or for a system rebuild.

disko is flexible, in that it supports most of the common formatting and partitioning options, including:

  • Disk layouts: GPT, MBR, and mixed.
  • Partition tools: LVM, mdadm, LUKS, and more.
  • Filesystems: ext4, btrfs, ZFS, bcachefs, tmpfs, and others.

It can work with these in various configurations and orders, and supports recursive layouts.

How to use disko

Disko doesn't require installation: it can be run directly from nix-community repository. The Quickstart Guide documents how to run Disko in its simplest form when installing NixOS. Alternatively, you can also use the new disko-install tool, which combines disko and nixos-install into one step.

For information on other use cases, including upgrading from an older version of disko, using disko without NixOS and downloading the module, see the How To Guide

For more detailed options, such as command line switches, see the Reference Guide

To access sample configurations for commonly-used disk layouts, refer to the examples provided.

Disko can be also used to create disk images.

Sample Configuration and CLI command

A simple disko configuration may look like this:

{
  disko.devices = {
    disk = {
      my-disk = {
        device = "/dev/sda";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            ESP = {
              type = "EF00";
              size = "500M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
                mountOptions = [ "umask=0077" ];
              };
            };
            root = {
              size = "100%";
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
          };
        };
      };
    };
  };
}

If you'd saved this configuration in /tmp/disk-config.nix, and wanted to create a disk named /dev/sda, you would run the following command to partition, format and mount the disk.

sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount /tmp/disk-config.nix

This tool is used by nixos-anywhere, which carries out a fully-automated remote install of NixOS.

We also acknowledge https://github.com/NixOS/nixpart, the conceptual ancestor of this project.

Licensing and Contribution details

This software is provided free under the MIT Licence.

If you want to contribute, check out CONTRIBUTING.md.

Get in touch

We have a public matrix channel at disko.


This project is supported by Numtide. Untitledpng

We are a team of independent freelancers that love open source.  We help our customers make their project lifecycles more efficient by:

  • Providing and supporting useful tools such as this one
  • Building and deploying infrastructure, and offering dedicated DevOps support
  • Building their in-house Nix skills, and integrating Nix with their workflows
  • Developing additional features and tools
  • Carrying out custom research and development.

Contact us if you have a project in mind, or if you need help with any of our supported tools, including this one. We'd love to hear from you.