!oNSIfazDqEcwhcOjSL:matrix.org

disko

364 Members
disko - declarative disk partitioning - https://github.com/nix-community/disko92 Servers

Load older messages


SenderMessageTime
21 Sep 2024
@matthewcroughan:defenestrate.itmatthewcroughanRight now I have all this boiler plate in my disko.nix's15:50:41
@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
  '';

15:50:43
@matthewcroughan:defenestrate.itmatthewcroughanbasically stealing the bits from nixpkgs that expand on boot15:50:52
@matthewcroughan:defenestrate.itmatthewcroughan
                  postMountHook = toString (pkgs.writeScript "postMountHook.sh" ''
                    touch /mnt/disko-first-boot
                  '');

15:51:10
@matthewcroughan:defenestrate.itmatthewcroughan *
                  postMountHook = toString (pkgs.writeScript "postMountHook.sh" ''
                    touch /mnt/disko-first-boot
                  '');
15:51:12
@matthewcroughan:defenestrate.itmatthewcroughanLassulus said something about how this shouldn't be a disko feature at all, because of what you're saying about the filesystem specific code15:51:35
@matthewcroughan:defenestrate.itmatthewcroughanbut if we're gonna have to do it for auto calculating the imageSize, this might as well get dealt with at the same time15:52:02
@matthewcroughan:defenestrate.itmatthewcroughanI like that disko doesn't inject any extra stuff, unless the user specifies it via postVM though, having to DIY it feels bad though15:52:21
@matthewcroughan:defenestrate.itmatthewcroughan * I like that disko doesn't inject any extra stuff, unless the user specifies it via postVM though, having to DIY it feels bad too though15:52:27
@matthewcroughan:defenestrate.itmatthewcroughan * I like that disko doesn't inject any extra stuff, unless the user specifies it via postVM/postMount though, having to DIY it feels bad too though15:52:38
@joerg:thalheim.ioMic92doesn't systemd has some auto disk increase thingy?15:53:07
@matthewcroughan:defenestrate.itmatthewcroughanYeah but that only works well with systemd-reparted15:53:15
@matthewcroughan:defenestrate.itmatthewcroughanand reparted sucks because it cannot build images for embedded devices due to demanding everything implement GPT15:53:27
@matthewcroughan:defenestrate.itmatthewcroughan * and reparted sucks because it cannot build images for embedded devices due to demanding everything implement GPT properly15:53:32
@joerg:thalheim.ioMic92I think on-first-boot resizing is also different from disk images15:53:37
@matthewcroughan:defenestrate.itmatthewcroughanyou can't make an image with arbitrary start sector for example, where you would put uboot15:53:49
@matthewcroughan:defenestrate.itmatthewcroughanI've played a lot with both disko and reparted, and reparted is only nice for x86 uefi, everything else is out of the window15:54:32
@matthewcroughan:defenestrate.itmatthewcroughandisko can do everything15:54:41
@matthewcroughan:defenestrate.itmatthewcroughanI also tried to coerce systemd into resizing the things that disko creates, but that can't be done, at least I couldn't figure it out15:55:14
@matthewcroughan:defenestrate.itmatthewcroughanafaik you can only coerce systemd into doing that for you if you have made everything with reparted15:55:35
@matthewcroughan:defenestrate.itmatthewcroughan
In reply to @joerg:thalheim.io
I think on-first-boot resizing is also different from disk images
it is, but you can't do it without impacting the disk image
16:02:11
@matthewcroughan:defenestrate.itmatthewcroughanYou have to put some state on the disk image, so it knows that it's the first boot, there's no other strategy I know of that could indicate a disk image is being booted for the first time16:03:13
@matthewcroughan:defenestrate.itmatthewcroughanzfs autoResize is cool though, only zfs could do that however16:03:45
@matthewcroughan:defenestrate.itmatthewcroughanthe strategy of touching a file in the disk image so the system knows when first-boot is happening, is filesystem agnostic16:04:20
@joerg:thalheim.ioMic92can you not the sentinil file the other way around?16:05:26
@joerg:thalheim.ioMic92And create the file after the resize?16:05:35
@matthewcroughan:defenestrate.itmatthewcroughanThat would mean that on any boot, it attempts to resize, unless told not to?16:06:03
@matthewcroughan:defenestrate.itmatthewcroughanas opposed to attempting the resize only when told to16:06:49
@matthewcroughan:defenestrate.itmatthewcroughanfeels risky to me, unless we trust the filesystem utils very much16:07:09
@joerg:thalheim.ioMic92Well it only tries it once16:07:54

Show newer messages


Back to Room ListRoom Version: 10