Skip to content

Commit

Permalink
docs(disk-partitioning): document disko setup
Browse files Browse the repository at this point in the history
  • Loading branch information
brckd committed Dec 26, 2024
1 parent 900b0dc commit ba729b4
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig({
{
label: "Features",
items: [
{ slug: "features/disk-partitioning" },
{ slug: "features/secure-boot" },
{ slug: "features/tpm-disk-unlock" },
],
Expand Down
Binary file modified docs/bun.lockb
Binary file not shown.
89 changes: 89 additions & 0 deletions docs/src/content/docs/features/disk-partitioning.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: Disk Partitioning
description: Learn how to automate drive partitioning with disko.
---

import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components";

<Aside>
This guide assumes that you have [set up your NixOS environment](set-up-nix),
which includes enabling flakes and entering the Git repository. The disko
setup has to be performed before installing the NixOS system however.
</Aside>

When reinstalling NixOS from an existing configuration, the only manual step is often disk partitioning. But even this step can be automated using disko.

## Setup

To create a new disko configuration, copy one of the existing disko configurations into `configs/nixos/$(hostname)/disko.nix`.

<Steps>
<ol>
<li>

Copy an existing disko configuration into the host's configuration directory.

<Tabs syncKey="nix-environment">
<TabItem label="NixOS">

```zsh
cp configs/nixos/desktop/disko.nix configs/nixos/$(hostname)
```

</TabItem>
</Tabs>

</li>
<li>

Edit the disk layout according to your needs. Replace `disko.devices.disk.main.device` with the name listed by `lsblk` for your main drive.

<Tabs syncKey="nix-environment">
<TabItem label="NixOS">

```zsh
sudo lsblk
```

</TabItem>
</Tabs>

</li>
<li>

Apply the disko configuration.

<Tabs syncKey="nix-environment">
<TabItem label="NixOS">

```zsh
sudo nix run github:nix-community/disko/latest -- --mode destroy,format,mount configs/nixos/$(hostname)/disko.nix
```

</TabItem>
</Tabs>

</li>
<li>

Generate a new hardware configuration excluding the filesystem configurations provided by disko.

<Tabs syncKey="nix-environment">
<TabItem label="NixOS">

```zsh
sudo nixos-generate-config --no-filesystems --root /mnt --dir configs/nixos/$(hostname)
rm configs/nixos/$(hostname)/{configuration,hardware}.nix
cp configs/nixos/$(hostname)/hardware-configuration.nix configs/nixos/$(hostname)/hardware.nix
```

</TabItem>
</Tabs>

</li>
</ol>
</Steps>

## Further reading

- [disko documentation](https://github.com/nix-community/disko/blob/master/docs/INDEX.md)

0 comments on commit ba729b4

Please sign in to comment.