!oNSIfazDqEcwhcOjSL:matrix.org

disko

307 Members
disko - declarative disk partitioning - https://github.com/nix-community/disko78 Servers

Load older messages


SenderMessageTime
19 May 2024
@matthewcroughan:defenestrate.itmatthewcroughan Ah and instead of e2fsprogs I need ${bcachefs-tools}/bin/bcachefs resize $rootpart 14:45:07
@matthewcroughan:defenestrate.itmatthewcroughan * Ah and instead of e2fsprogs I need ${bcachefs-tools}/bin/bcachefs resize $rootPart 14:45:09
@matthewcroughan:defenestrate.itmatthewcroughan It feels like disko should help with resizing on first boot, but curious what you think lassulus 14:45:35
@matthewcroughan:defenestrate.itmatthewcroughanfeels like disko already knows a lot of the info that would help here14:46:00
@lassulus:lassul.uslassulushmm, resizing is not really delcarative? :D and not sure what the interface would look like14:46:11
@matthewcroughan:defenestrate.itmatthewcroughansystemd-repart has a really nice setup14:46:41
@matthewcroughan:defenestrate.itmatthewcroughan

systemd-repart (mostly) operates in a purely incremental mode: it only grows existing and adds new partitions; it does not shrink, delete or move existing partitions. The service is intended to be run on every boot, but when it detects that the partition table already matches the installed repart.

14:46:46
@matthewcroughan:defenestrate.itmatthewcroughanWhich more or less sound exactly like disko's philosophy, and some of the goals you have for your own incremental mode14:47:09
@matthewcroughan:defenestrate.itmatthewcroughanThis ended up being the final disko.nix for a pi to boot using bcachefs17:54:42
@matthewcroughan:defenestrate.itmatthewcroughan
{
  boot.postBootCommands = ''
    # On the first boot, resize the disk
    if [ -f /disko-first-boot ]; then
      set -euo pipefail
      set -x
      # Figure out device names for the boot device and root filesystem.
      rootPart=$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE /)
      bootDevice=$(lsblk -npo PKNAME $rootPart)
      partNum=$(lsblk -npo MAJ:MIN $rootPart | ${pkgs.gawk}/bin/awk -F: '{print $2}')

      # Resize the root partition and the filesystem to fit the disk
      echo ",+," | sfdisk -N$partNum --no-reread $bootDevice
      ${pkgs.parted}/bin/partprobe
      ${pkgs.bcachefs-tools}/bin/bcachefs device resize $rootPart

      # Prevents this from running on later boots.
      rm -f /disko-first-boot
    fi
  '';
  disko = {
    extraPostVM = ''
      ${pkgs.zstd}/bin/zstd --compress $out/*raw
      rm $out/*raw
    '';
    devices = {
      disk = {
        disk1 = {
          imageSize = "10G";
          type = "disk";
          device = "/dev/mmcblk0";
          postCreateHook = ''
            lsblk
            sgdisk -A 1:set:2 /dev/vda
          '';
          content = {
            type = "gpt";
            partitions = {
              firmware = {
                size = "30M";
                type = "EF00";
                content = {
                  type = "filesystem";
                  format = "vfat";
                  mountpoint = "/firmware";
                  postMountHook = toString (pkgs.writeScript "postMountHook.sh" ''
                    (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf *.dtb /mnt/firmware/)
                    cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin /mnt/firmware/u-boot-rpi4.bin
                    cp ${configTxt} /mnt/firmware/config.txt
                  '');
                };
              };
              boot = {
                size = "100M";
                content = {
                  type = "filesystem";
                  format = "ext4";
                  mountpoint = "/boot";
                };
              };
              root = {
                name = "root";
                size = "100%";
                content = {
                  type = "filesystem";
                  format = "bcachefs";
                  mountpoint = "/";
                  postMountHook = toString (pkgs.writeScript "postMountHook.sh" ''
                    touch /mnt/disko-first-boot
                  '');
                };
              };
            };
          };
        };
      };
    };
  };
}
17:54:46
@matthewcroughan:defenestrate.itmatthewcroughanhmm.. disko won't quite work for riscv due to its architecture, will it?18:37:30
@matthewcroughan:defenestrate.itmatthewcroughanThis same problem would be solved by running the vmTools on the hostPlatform, and allowing it to do binfmt, instead of treating the VM performing the disk partitioning/formatting as something that needs to run on the native platform18:38:17
@matthewcroughan:defenestrate.itmatthewcroughan * This same problem would be solved by running the vmTools on the hostPlatform, and allowing it to do binfmt, instead of treating the VM performing the disk partitioning/formatting as something that needs to run on the system arch of the nixosConfig18:38:37
@matthewcroughan:defenestrate.itmatthewcroughanMy next project was going to be making images for visionfivev1/218:42:05
@matthewcroughan:defenestrate.itmatthewcroughan * My next project was going to be making images for visionfivev1/2 that boot with bcachefs too18:42:13
@matthewcroughan:defenestrate.itmatthewcroughan

Is this perhaps another way that disko's architecture fails because of the hostPlatform issue?

corpo-disko-images> qemu-system-aarch64: could not load kernel '/nix/store/fqwx7jpif67dzqhiggnnj69nhch8jp23-kernel-modules/vmlinuz.efi'
error: build of '/nix/store/zzvgpqhc34ha13p2a70l2s5ya324safa-corpo-disko-images.drv' on 'ssh-ng://matthewcroughan@aarch64.nixos.community' failed: builder for '/nix/store/zzvgpqhc34ha13p2a70l2s5ya324safa-corpo-disko-images.drv' failed with exit code 1;
       last 2 log lines:
       > unable to handle EFI zboot image with "zstd22" compression
       > qemu-system-aarch64: could not load kernel '/nix/store/fqwx7jpif67dzqhiggnnj69nhch8jp23-kernel-modules/vmlinuz.efi'
       For full logs, run 'nix log /nix/store/zzvgpqhc34ha13p2a70l2s5ya324safa-corpo-disko-images.drv'.
20:51:22
@matthewcroughan:defenestrate.itmatthewcroughanWhy does disko care?20:51:25
@matthewcroughan:defenestrate.itmatthewcroughandisko is trying to load the kernel from my nixosConfig, but why? That should only be relevant for an installTest if anything20:53:51
@matthewcroughan:defenestrate.itmatthewcroughanYes.. inheriting the kernel from the host is not quite right https://github.com/nix-community/disko/blob/master/lib/make-disk-image.nix#L1321:11:43
@matthewcroughan:defenestrate.itmatthewcroughanhttps://github.com/qemu/qemu/blob/master/hw/core/loader.c#L92421:18:14
@matthewcroughan:defenestrate.itmatthewcroughanAnything other than a gzipped kernel is not supported in QEMU 21:18:31
@matthewcroughan:defenestrate.itmatthewcroughanFFFFFFFFFFFFFF21:18:34
@matthewcroughan:defenestrate.itmatthewcroughanAlthough it does highlight that disko shouldn't be using the target kernel, just to make the disk image for the target21:19:38
@matthewcroughan:defenestrate.itmatthewcroughanIt was me who implemented that though, so I should feel bad21:44:38
@matthewcroughan:defenestrate.itmatthewcroughanhttps://github.com/nix-community/disko/pull/46721:44:53
@matthewcroughan:defenestrate.itmatthewcroughanThe solution is uefi, but is there a use case for not using UEFI?22:05:38
@matthewcroughan:defenestrate.itmatthewcroughanI can make the PR, but wondering if I should make it boolean22:06:10
20 May 2024
@matthewcroughan:defenestrate.itmatthewcroughanhttps://github.com/nix-community/disko/pull/64308:46:42
@matthewcroughan:defenestrate.itmatthewcroughanCloser to finding memory leaks..09:34:35
@matthewcroughan:defenestrate.itmatthewcroughanI switched to systemd-boot from generic-extlinux, and now I'm getting the "Cannot allocate memory" all the time09:34:50

There are no newer messages yet.


Back to Room ListRoom Version: 10