nix-community / disko

Declarative disk partitioning and formatting using nix [maintainers=@Lassulus @Enzime]
MIT License
1.68k stars 184 forks source link

[Example] encrypted btrfs raid1 #799

Open Sk7Str1pe opened 2 days ago

Sk7Str1pe commented 2 days ago
{
  disko.devices = {
    disk = {
      disk0 = {
        type = "disk";
    device = "/dev/sdb";
    content = {
      type = "gpt";
      partitions = {
        crypted2 = {
          name = "crypt_raidp2";
          size = "100%";
          content = {
                type = "luks";
        name = "raidp2"; # this is DM name
          };
        };
      };
    };
      };
      disk1 = {
        type = "disk";
        device = "/dev/sda";
        content = {
          type = "gpt";
          partitions = {
            crypted1 = {
              size = "100%";
          name = "crypt_raidp1";
              content = {
                type = "luks";
        name = "raidp1";
        content = {
          type = "btrfs";
          extraArgs = [ "-f" "-m raid1 -d raid1" "/dev/mapper/raidp2"]; # raidp2 - DM name of 2nd disk
                  subvolumes = {
            "/" = {
                      mountpoint = "/mnt/SoftWare";
              mountOptions = [
                "rw" "relatime" "ssd" "discard=async" "space_cache=v2" "subvolid=5" "subvol=/"
              ];
            };
          };
        };
          };
        };
          };
        };
      };
    };
  };
}
Sk7Str1pe commented 2 days ago

Couldn't open pull request so opened here

iFreilicht commented 2 days ago

Have you tested this example? Can you boot from it?

Sk7Str1pe commented 2 days ago

I didn't tried to boot from it, I don't use this setup for main system, but yes I managed to get working raid and it seems to be possible to boot with this (if possible to determine 2 LUKS devices in kernel cmdline)

Sk7Str1pe commented 2 days ago

Can you boot from it?

Yes I tested in VM and it's bootable

Sk7Str1pe commented 2 days ago

@Lassulus new example, already tested on bare metal. Can be booted.

iFreilicht commented 1 day ago

Dude, chill. We'll get to it. If you want this to be merged quickly, make a PR and add a test for it. If you can't or don't want to do that, expect a change like this to take a little while.

Sk7Str1pe commented 1 day ago

I can't get how to become a collaborator

iFreilicht commented 1 day ago

You have to fork the repository first, see Fork a respository Then, you clone your fork as described in the link above, make the changes you want, and push them. When you then go back to your fork in the browser, you can open a pull request (see Creating a Pull Request from a Fork).

Once your PR is accepted and merged, the badge "Collaborator" will appear next to your username in discussions. Hope this helps!

Sk7Str1pe commented 1 day ago

Yay it helps, thx a lot!