Stream: nixos

Topic: Specifying UUID in diskio


view this post on Zulip Pratham Patel (Mar 11 2024 at 19:30):

Is there a way to specify UUIDs for partitions in diskio? Doing so would help me not update my ${hostname}-hardware-configuration.nix file everytime I need to clean-install on a host with same storage layout.

view this post on Zulip Srid (Mar 11 2024 at 22:41):

/dev/disk/by-{id,path}?

cf. https://github.com/nix-community/disko/issues/14

view this post on Zulip Pratham Patel (Mar 12 2024 at 01:45):

Not the target disk... specifying the UUIDs of the partitions created themselves.

view this post on Zulip Tim DeHerrera (Mar 12 2024 at 12:45):

Isn't diskio responsible for creating those partitions? I haven't used it but it was my impression that was the point of the tool.

view this post on Zulip Srid (Mar 12 2024 at 18:43):

You can get the same storage layout without necessarily fixing individual partition's UUID. See for example https://github.com/srid/nixos-config/blob/master/nixos/disko/trivial.nix

This layout remains the same across re-installs (wherein the partition UUID will change)

view this post on Zulip Srid (Mar 12 2024 at 18:44):

Or maybe I'm not understanding your question, @Pratham Patel

view this post on Zulip Shivaraj B H (Mar 13 2024 at 10:50):

If you use disko, you will not have to manually specify the UUID in hardware-configuration.nix, because disko manages it for you, if i am not wrong. I never had to do that at least.

view this post on Zulip Pratham Patel (Mar 13 2024 at 11:31):

@Srid This question came out of my migration to deploying nixos on my machines using flakes. Flakes mandate that all files be included in the git tree and therefore, it's not possible to have the hardware-configuration.nix in the repo in advance. Specifying the UUIDs for each partition/filesystem in diskio would be nice for this, where the hardware-configuration.nix file already picks up the devices using the /dev/disk/by-uuid path. :)

view this post on Zulip Srid (Mar 13 2024 at 12:40):

So you want to introduce disko on an already-installed NixOS machine?

This looks to be the same problem as https://github.com/juspay/remote-development/issues/11

view this post on Zulip Srid (Mar 13 2024 at 12:41):

This may be relevant: https://github.com/nix-community/disko/issues/295

view this post on Zulip Pratham Patel (Mar 13 2024 at 12:44):

Sort of, yes! :)

view this post on Zulip Pratham Patel (Mar 14 2024 at 15:12):

Finally got some free time to poke around in the disko src and noticed this line: https://github.com/nix-community/disko/blob/f6b72bfed7c57997aa5dccd94a3ebbc4cb824b04/lib/types/filesystem.nix#L48

So, the pseudo code would be something like:

  1. Check if filesystem supports the -U or -u option to specify the UUID to assign to, such that, it appears as /dev/disk/by-uuid/${UUID}.
  2. Append the string -U ${UUID} if some option, let's assume customUUID is specified.

That way, the same disko config _and_ same hardware-configuration.nix can be used, even when the disk is reformatted, preserving the UUID, resulting in not needing to update the hardware-configuration.nix file, at all

view this post on Zulip Srid (Mar 26 2024 at 12:23):

@Pratham Patel Is this relevant? https://github.com/nix-community/disko/pull/548#issuecomment-1967664266

view this post on Zulip Pratham Patel (Mar 27 2024 at 01:35):

huh, this is better than what I was looking for! thank you :D


Last updated: Nov 15 2024 at 12:33 UTC