disko-install combines disko and nixos-install into a single command.
Example usage:
sudo ./disko-install --flake /someflake#eva --disk sda /dev/zvol/zroot/test
Before this change, if you created a systemd service that ran
“disko --mode disko <path-to-config>”, then you would (probably) get
this error:
disk-deactivate: line 6: /dev/stderr: No such device or address
Since disk-deactivate uses “set -e”, that error would prevent
disk-deactivate from actually deactivating any disks. The problem is
that disk-deactivate tries to print text to stderr by doing this:
echo "Text" >/dev/stderr
systemd.exec(5) explains why that doesn’t work and goes on to say [1]:
> This means when executing shell scripts the construct
> **echo "hello" > /dev/stderr** for writing text to stderr will not
> work. To mitigate this use the construct **echo "hello" >&2** instead,
> which is mostly equivalent and avoids this pitfall.
[1]: <https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#StandardOutput=>
---
You can test this commit by doing the following:
1. Download a copy of this gist:
<https://gist.github.com/Jayman2000/60b483659e89283716582ac38856dca6>
2. Build a custom NixOS installation ISO that contains a systemd service
that runs disko:
nix-build --arg diskoDir <path-to-disko-repo> <path-to-gist>
Once that command finishes, the ISO will be in ./result/iso/.
3. Create a VM. Make sure that it has a VirtIO disk that’s more than
500M large. Also make sure that it has an optical disc drive.
4. Put the ISO file from step 2 into the VM’s optical disc drive.
5. Turn on the VM and boot into the installation ISO.
6. Start the systemd service:
sudo systemctl start disko-test
7. Check journalctl to see if there are any errors related to
disk-deactivate.
On 4Kn disks, 2048-sector alignment is equivalent to 8 MiB which is
excessive. Moreover, there is no point in specifying _any_ alignment
at all because sgdisk defaults to 1 MiB already.
Fixes#497.
The vmTools in nixpkgs shuts the VM down with poweroff -f, which does
not cleanly umount the filesystems. This may lead to filesystem
corruption on the newly created image.
this is useful in cases where the target machine has
a pre-configured RAID setup, as otherwise disko would
wipe the partition tables and create new ones but would
not be able to inform the kernel about it, as the old
raid was still in use.
Also refactor `zpool` type to use `zfs_fs` to construct the root dataset
for the zpool, which means we no longer need to duplicate the dataset
create and mount logic inside the `zpool` type.
fixes an error when using this minimal configuration:
```nix
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11") { };
disko = fetchTarball "https://github.com/nix-community/disko/tarball/master";
in
pkgs.nixos {
imports = [
"${disko}/module.nix"
"${disko}/example/hybrid.nix"
];
}
```
when running:
```console
$ nix-build
...
error: 'default' at /nix/store/y981rwszq9yi36rvvz2vrr6hb22si0hc-source/lib/default.nix:391:23 called with unexpected argument 'system'
```