mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
2540cc069f
9 changed files with 65 additions and 32 deletions
|
@ -41,7 +41,7 @@ recursive layouts.
|
|||
|
||||
Disko doesn't require installation: it can be run directly from nix-community
|
||||
repository. The [Quickstart Guide](./docs/quickstart.md) documents how to run
|
||||
Disko in its simplest form when installing NixOS. Alternatively you can
|
||||
Disko in its simplest form when installing NixOS. Alternatively, you can
|
||||
also use the new [disko-install](./docs/disko-install.md) tool, which combines
|
||||
the `disko` and `nixos-install` into one step.
|
||||
|
||||
|
@ -118,8 +118,10 @@ this project.
|
|||
This software is provided free under the
|
||||
[MIT Licence](https://opensource.org/licenses/MIT).
|
||||
|
||||
If you would like to become a contributor, please see our
|
||||
[contribution guidelines.](https://github.com/numtide/docs/contribution-guidelines.md)
|
||||
## Get in touch
|
||||
|
||||
We have a public matrix channel at
|
||||
[disko](https://matrix.to/#/#disko:nixos.org).
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ In the this example we create a flake containing a nixos configuration for
|
|||
|
||||
The script will generate the actual image outside of the nix store in the
|
||||
current working directory. The create image names depend on the names used in
|
||||
`disko.devices.disk` attrset in the NixOS configuration. In our code example it will
|
||||
produce the following image:
|
||||
`disko.devices.disk` attrset in the NixOS configuration. In our code example
|
||||
it will produce the following image:
|
||||
|
||||
```
|
||||
$ ls -la vdb.raw
|
||||
|
|
|
@ -15,21 +15,42 @@ existing partitions. Dual booting with other operating systems is not supported.
|
|||
|
||||
### Step 1: Choose a Disk Configuration
|
||||
|
||||
Configurations for the most common disk layouts are provided in the
|
||||
[examples directory](https://github.com/nix-community/disko/tree/master/example)
|
||||
of the `disko` repository. Decide which of these layouts best suits your
|
||||
requirements. If you're not sure which layout to pick, use the
|
||||
[hybrid](https://github.com/nix-community/disko/blob/master/example/hybrid.nix)
|
||||
Real-world templates are provided in this [repository](https://github.com/nix-community/disko-templates).
|
||||
|
||||
More disk layouts for all filesystems can be also found in the
|
||||
[example](https://github.com/nix-community/disko/tree/master/example) directory
|
||||
of disko. However these examples are also used for regression tests in disko and
|
||||
may have uncommon options in them to fully exercise all features of disko, that
|
||||
you may need to change or remove.
|
||||
|
||||
Decide which of these layouts best suits your requirements. If you're not sure
|
||||
which layout to pick, use the
|
||||
[single-disk-ext4](https://github.com/nix-community/disko-templates/blob/main/single-disk-ext4/disko-config.nix)
|
||||
configuration. This layout is compatible with both BIOS and EFI systems.
|
||||
|
||||
Refer to the [reference manual](./reference.md) for more information about the
|
||||
sample layouts and how to build your own configuration.
|
||||
|
||||
Once you've chosen your layout, you'll need to make a note of the URL to the raw
|
||||
file. To do this, open the file in Github. Immediately below the list of
|
||||
contributors, you will see a button labelled 'RAW' near the right hand side.
|
||||
Click this. The URL of the raw file will appear in the search bar of your
|
||||
browser. It will look something like this:
|
||||
To copy a template use this command in your nixos configuration directory:
|
||||
|
||||
```
|
||||
nix flake init --template github:nix-community/disko-templates#single-disk-ext4
|
||||
```
|
||||
|
||||
This will write a file called `disko-config.nix` into the current directory.
|
||||
Import this file in your NixOS configuration:
|
||||
|
||||
```nix
|
||||
{
|
||||
imports = [ ./disko-config.nix ];
|
||||
}
|
||||
```
|
||||
|
||||
If you want to choose a layout from the disko example directory instead, you'll
|
||||
need to make a note of the URL to the raw file. To do this, open the file in
|
||||
Github. Immediately below the list of contributors, you will see a button
|
||||
labelled 'RAW' near the right hand side. Click this. The URL of the raw file
|
||||
will appear in the search bar of your browser. It will look something like this:
|
||||
|
||||
```
|
||||
https://raw.githubusercontent.com/nix-community/disko/master/example/hybrid.nix
|
||||
|
|
|
@ -41,4 +41,3 @@ Options:
|
|||
* --debug
|
||||
run with set -x
|
||||
```
|
||||
|
||||
|
|
|
@ -58,16 +58,21 @@ for example like this:
|
|||
|
||||
## Remediation
|
||||
|
||||
The new GPT layout (`type = "gpt"`) uses partlabels to realize the partiton numbering. For this reason you have to manually set up partition labels, if you want to resolve this issue.
|
||||
The new GPT layout (`type = "gpt"`) uses partlabels to realize the partiton
|
||||
numbering. For this reason you have to manually set up partition labels, if you
|
||||
want to resolve this issue.
|
||||
|
||||
### Create GPT partition labels
|
||||
|
||||
For each partition involved, create the partition label from these components:
|
||||
|
||||
- The partition number (e.g. /dev/nvme0n**1**, or /dev/sda**1**)
|
||||
- The parent type in your disko config (value of `disko.device.disk.example.type = "disk";`)
|
||||
- The parent name in your disko config (attribute name of `disko.devices.disk.example`, so `example` in this example)
|
||||
- The partition name in your disko config (attribute name of `disko.devices.disk.content.partitions.*.name`)
|
||||
- The parent type in your disko config (value of
|
||||
`disko.device.disk.example.type = "disk";`)
|
||||
- The parent name in your disko config (attribute name of
|
||||
`disko.devices.disk.example`, so `example` in this example)
|
||||
- The partition name in your disko config (attribute name of
|
||||
`disko.devices.disk.content.partitions.*.name`)
|
||||
|
||||
```bash
|
||||
# sgdisk -c 1:disk-example-ESP /dev/nvme0n1
|
||||
|
@ -84,14 +89,18 @@ Make the following changes to your disko configuration:
|
|||
|
||||
1. Set `disko.devices.disk.example.content.type = "gpt"`
|
||||
1. Remove `disko.devices.disk.example.format`
|
||||
1. Convert `disko.devices.disk.example.partitions` to an attribute set and promote the `name` field to the key for its partition
|
||||
1. Add a `priority` field to each partition, to reflect the intended partition number
|
||||
1. Convert `disko.devices.disk.example.partitions` to an attribute set and
|
||||
promote the `name` field to the key for its partition
|
||||
1. Add a `priority` field to each partition, to reflect the intended partition
|
||||
number
|
||||
|
||||
Then rebuild your system and reboot.
|
||||
|
||||
### Recovering from mistake
|
||||
|
||||
If you made a mistake here, your system will be waiting for devices to appear, and then run into timeouts. You can easily recover from this, since rebooting into an old generation will still use the legacy way of numbering of partitions.
|
||||
If you made a mistake here, your system will be waiting for devices to appear,
|
||||
and then run into timeouts. You can easily recover from this, since rebooting
|
||||
into an old generation will still use the legacy way of numbering of partitions.
|
||||
|
||||
## Result
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1717459389,
|
||||
"narHash": "sha256-I8/plBsua4/NZ5bKgj+z7/ThiWuud1YFwLsn1QQ5PgE=",
|
||||
"lastModified": 1717868076,
|
||||
"narHash": "sha256-c83Y9t815Wa34khrux81j8K8ET94ESmCuwORSKm2bQY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3b01abcc24846ae49957b30f4345bab4b3f1d14b",
|
||||
"rev": "cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -82,9 +82,11 @@ let
|
|||
QEMU_OPTS = lib.concatStringsSep " " ([
|
||||
"-drive if=pflash,format=raw,unit=0,readonly=on,file=${pkgs.OVMF.firmware}"
|
||||
"-drive if=pflash,format=raw,unit=1,file=efivars.fd"
|
||||
] ++ builtins.map (disk:
|
||||
] ++ builtins.map
|
||||
(disk:
|
||||
"-drive file=${disk.name}.raw,if=virtio,cache=unsafe,werror=report,format=raw"
|
||||
) (lib.attrValues nixosConfig.config.disko.devices.disk));
|
||||
)
|
||||
(lib.attrValues nixosConfig.config.disko.devices.disk));
|
||||
in
|
||||
{
|
||||
pure = vmTools.runInLinuxVM (pkgs.runCommand name
|
||||
|
|
Loading…
Reference in a new issue