- Notifications
You must be signed in to change notification settings - Fork226
Declarative disk partitioning and formatting using nix [maintainers=Lassulus Enzime iFreilicht Mic92 phaer]
License
nix-community/disko
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
NixOS is a Linux distribution where everything is described as code, with oneexception: during installation, the disk partitioning and formatting are manualsteps.disko aims to correct this sad 🤡 omission.
This is especially useful for unattended installations, re-installation after asystem crash or for setting up more than one identical server.
disko can either be used after booting from a NixOS installer, or inconjunction withnixos-anywhere ifyou're installing remotely.
Before usingdisko, the specifications of the disks, partitions, type offormatting and the mount points must be defined in a Nix configuration. You canfindexamples of typical configurations in the Nix communityrepository, 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 asystem rebuild.
disko is flexible, in that it supports most of the common formatting andpartitioning 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 supportsrecursive layouts.
Disko doesn't require installation: it can be run directly from nix-communityrepository. TheQuickstart Guide documents how to runDisko in its simplest form when installing NixOS. Alternatively, you can alsouse the newdisko-install tool, which combinesdisko
andnixos-install
into one step.
For information on other use cases, including upgrading from an older version ofdisko, usingdisko without NixOS and downloading the module, see theHow To Guide
For more detailed options, such as command line switches, see theReference Guide
To access sample configurations for commonly-used disk layouts, refer to theexamples provided.
Disko can be also used to createdisk images.
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 createa disk named /dev/sda, you would run the following command to partition, formatand 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 bynixos-anywhere, which carries out afully-automated remote install of NixOS.
We also acknowledgehttps://github.com/NixOS/nixpart, the conceptual ancestor ofthis project.
This software is provided free under theMIT Licence.
If you want to contribute, check outCONTRIBUTING.md.
We have a public matrix channel atdisko.
This project is supported byNumtide.
We are a team of independent freelancers that love open source. We help ourcustomers 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 ifyou need help with any of our supported tools, including this one. We'd love tohear from you.
About
Declarative disk partitioning and formatting using nix [maintainers=Lassulus Enzime iFreilicht Mic92 phaer]