Configure the disk

The first phase partitions, formats, and mounts the target disk. It lays out the filesystem declaratively with disko, as a GPT disk with:

  • a btrfs root, all mounted with compress=zstd and noatime, split into subvolumes:
    • @/
    • @home/home
    • @nix/nix
  • a boot partition chosen automatically from the detected firmware: an EFI System Partition on UEFI machines, or a small bios_grub partition on legacy BIOS machines;
  • optionally, full-disk LUKS encryption of the root;
  • optionally, a swap partition.

Start it from the menu, or directly:

[bash]: Run this on your workstation:
setup disk

It detects your firmware (UEFI vs. legacy BIOS) automatically, then shows the disks you can install onto:

== Configure a disk for NixOS ==
Firmware detected: UEFI

Select the target disk:
> /dev/nvme0n1   --   3.6T     --   CT4000P3PSSD8     --   (NVME, SSD)
  /dev/sda       --   931.5G   --   Samsung SSD 870   --   (SATA, SSD)

Disks that are currently in use by the running system – most importantly the live USB stick you booted from – are hidden, so you cannot accidentally wipe them. (Pass --include-mounted to override this, but that is rarely what you want.)

Encryption

? Encrypt the disk with LUKS? (disko will prompt for a passphrase during formatting) (y/N)

Optionally encrypt the root with LUKS. Answer y and the btrfs root is placed inside a LUKS2 container; disko itself prompts you to set (and confirm) the passphrase during formatting, and the system prompts for it again at every boot to unlock the disk. The tool never handles the passphrase – so keep it safe, it cannot be recovered.

If you also add swap (below), the swap partition is re-keyed with a random passphrase on every boot, so it never leaks RAM contents in plaintext on an otherwise-encrypted disk. The trade-off is that this rules out hibernation (suspend-to-disk), since the swap contents are unreadable after a reboot.

Encryption is a fresh-install choice only: an existing encrypted disk is not recognized as a reusable btrfs layout, so the reinstall option below is not offered for it.

Swap

Detected RAM: 15.3G.
? Add a swap partition? (recommended for low-RAM machines) (y/N)
? Swap size (e.g. 8G, 2048M) (8G)

Optionally add a swap partition. This matters most on low-RAM machines: the live ISO’s Nix store is held in RAM (tmpfs), so without swap, a large download or build during nixos-install can exhaust memory. The default size is 8G.

Confirm and apply

Because this erases the disk, you have to re-type the device path to confirm, and then approve a review screen:

About to DESTROY everything on: /dev/nvme0n1
? Type '/dev/nvme0n1' to confirm

================ Review =================
Target disk:  /dev/nvme0n1
Firmware:     UEFI (ESP /boot)
Filesystem:   btrfs
Encryption:   LUKS2 (passphrase set during format, prompted at boot)
Subvolumes:   @ -> /, @home -> /home, @nix -> /nix
Swap:         8G (random-key encrypted)
Config:       /tmp/nixos-disk-xxxx/disko.nix
=========================================

⚠️  This ERASES ALL DATA on /dev/nvme0n1 and mounts the new
    filesystems under /mnt.

    disko will prompt you to set the LUKS passphrase during
    formatting -- keep it safe, it cannot be recovered.

? Proceed? (y/N)

Once you confirm, it fetches and runs disko (over the network) to wipe the disk, create the partitions and subvolumes, and mount everything under /mnt. The generated layout is saved into the new system at /mnt/etc/nixos/disko.nix, where the next phase picks it up.

Reinstalling over an existing layout

If the disk you select already has this btrfs layout (@, @home, @nix) from a previous install, setup disk offers a reinstall option instead of erasing everything:

⚠️  /dev/nvme0n1 already has a NixOS btrfs layout (@, @home, @nix).
? How do you want to install?
> Reinstall -- keep /home and /nix, wipe / and reinstall the bootloader
  Fresh install -- ERASE the entire disk and recreate everything

A reinstall wipes only @ (the root filesystem) and reformats the ESP for a fresh bootloader, but keeps @home and @nix, so your home directory (including the config repo generated in the next phase) and the Nix store survive. After a reinstall you skip Configure Host (the preserved config repo is reused) and go straight to Install, which rebuilds that existing configuration. setup nixos detects this and skips the host phase for you.

When the disk is ready and mounted under /mnt, continue to the next phase.

// settings
theme:
fx: