2023-05-09 12:38:07 +03:00
|
|
|
|
# disko - Declarative disk partitioning
|
2018-09-11 21:42:55 +03:00
|
|
|
|
|
2023-04-16 18:04:15 +03:00
|
|
|
|
<!-- Generated with bing image generator (which uses dall-e-2): edge-gpt-image --prompt "Disco ball shooting a laser beam at one hard drive" -->
|
2023-06-04 17:45:48 +03:00
|
|
|
|
|
|
|
|
|
<img title="" src="./docs/logo.jpeg" alt="Project logo" width="274">
|
|
|
|
|
|
|
|
|
|
[Documentation Index](./docs/INDEX.md)
|
2023-04-16 18:04:15 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
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.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
This is especially useful for unattended installations, re-installation after a
|
|
|
|
|
system crash or for setting up more than one identical server.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
## Overview
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
**disko** can either be used after booting from a NixOS installer, or in
|
|
|
|
|
conjunction with [nixos-anywhere](https://github.com/numtide/nixos-anywhere) if
|
|
|
|
|
you're installing remotely.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
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](./example) of typical configurations in the Nix community
|
|
|
|
|
repository, and use one of these as the basis of your own configuration.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
You can keep your configuration and re-use it for other installations, or for a
|
|
|
|
|
system rebuild.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
**disko** is flexible, in that it supports most of the common formatting and
|
|
|
|
|
partitioning options, including:
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
- Disk layouts: GPT, MBR, and mixed.
|
|
|
|
|
- Partition tools: LVM, mdadm, LUKS, and more.
|
|
|
|
|
- Filesystems: ext4, btrfs, ZFS, bcachefs, tmpfs, and others.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
It can work with these in various configurations and orders, and supports
|
|
|
|
|
recursive layouts.
|
2023-04-15 17:04:05 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
## How to use disko
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
Disko doesn't require installation: it can be run directly from nix-community
|
|
|
|
|
repository. The [Quickstart Guide](./docs/quickstart.md) documents how to run
|
2024-04-29 18:41:01 +03:00
|
|
|
|
Disko in its simplest form when installing NixOS. Alternativly you can
|
|
|
|
|
also use the new [disko-install](./docs/disko-install.md) tool, which combines
|
|
|
|
|
the `disko` and `nixos-install` into one step.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
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](./docs/HowTo.md)
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
For more detailed options, such as command line switches, see the
|
|
|
|
|
[Reference Guide](./docs/reference.md)
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
To access sample configurations for commonly-used disk layouts, refer to the
|
|
|
|
|
[examples](./example) provided.
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2024-04-29 18:41:01 +03:00
|
|
|
|
Disko can be also used to create [disk images](./docs/disko-images.md).
|
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
## Sample Configuration and CLI command
|
2022-11-02 20:58:36 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
A simple disko configuration may look like this:
|
2023-02-01 16:52:46 +03:00
|
|
|
|
|
2023-12-21 18:50:48 +03:00
|
|
|
|
```nix
|
2023-12-21 01:52:34 +03:00
|
|
|
|
{
|
2023-10-02 19:52:49 +03:00
|
|
|
|
disko.devices = {
|
|
|
|
|
disk = {
|
2023-12-21 14:36:17 +03:00
|
|
|
|
my-disk = {
|
2023-12-21 01:52:34 +03:00
|
|
|
|
device = "/dev/sda";
|
2023-10-02 19:52:49 +03:00
|
|
|
|
type = "disk";
|
|
|
|
|
content = {
|
|
|
|
|
type = "gpt";
|
|
|
|
|
partitions = {
|
|
|
|
|
ESP = {
|
2024-01-08 20:59:37 +03:00
|
|
|
|
type = "EF00";
|
2023-10-02 19:52:49 +03:00
|
|
|
|
size = "500M";
|
|
|
|
|
content = {
|
|
|
|
|
type = "filesystem";
|
|
|
|
|
format = "vfat";
|
|
|
|
|
mountpoint = "/boot";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
root = {
|
|
|
|
|
size = "100%";
|
|
|
|
|
content = {
|
|
|
|
|
type = "filesystem";
|
|
|
|
|
format = "ext4";
|
|
|
|
|
mountpoint = "/";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-08-05 18:23:24 +03:00
|
|
|
|
};
|
2022-10-23 13:29:30 +03:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-05 12:56:38 +03:00
|
|
|
|
If you'd saved this configuration in /tmp/disk-config.nix, and wanted to create
|
2024-04-21 22:25:44 +03:00
|
|
|
|
a disk named /dev/sda, you would run the following command to partition, format
|
|
|
|
|
and mount the disk.
|
2018-09-11 21:42:55 +03:00
|
|
|
|
|
2023-12-25 01:30:36 +03:00
|
|
|
|
```console
|
2024-04-05 12:56:38 +03:00
|
|
|
|
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/disk-config.nix
|
2023-06-05 11:23:08 +03:00
|
|
|
|
```
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
## Related Tools
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
This tool is used by
|
|
|
|
|
[nixos-anywhere](https://github.com/numtide/nixos-anywhere), which carries out a
|
|
|
|
|
fully-automated remote install of NixOS.
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
We also acknowledge https://github.com/NixOS/nixpart, the conceptual ancestor of
|
|
|
|
|
this project.
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
## Licensing and Contribution details
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
This software is provided free under the
|
|
|
|
|
[MIT Licence](https://opensource.org/licenses/MIT).
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
If you would like to become a contributor, please see our
|
|
|
|
|
[contribution guidelines.](https://github.com/numtide/docs/contribution-guidelines.md)
|
2022-10-23 13:29:30 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
---
|
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
This project is supported by [Numtide](https://numtide.com/).
|
|
|
|
|
![Untitledpng](https://codahosted.io/docs/6FCIMTRM0p/blobs/bl-sgSunaXYWX/077f3f9d7d76d6a228a937afa0658292584dedb5b852a8ca370b6c61dabb7872b7f617e603f1793928dc5410c74b3e77af21a89e435fa71a681a868d21fd1f599dd10a647dd855e14043979f1df7956f67c3260c0442e24b34662307204b83ea34de929d)
|
2018-09-11 21:42:55 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
We are a team of independent freelancers that love open source. We help our
|
|
|
|
|
customers make their project lifecycles more efficient by:
|
2019-09-16 12:56:55 +03:00
|
|
|
|
|
2023-05-09 12:38:07 +03:00
|
|
|
|
- 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.
|
2019-09-16 12:56:55 +03:00
|
|
|
|
|
2023-09-15 08:56:40 +03:00
|
|
|
|
[Contact us](https://numtide.com/contact) 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.
|