!DBFhtjpqmJNENpLDOv:nixos.org

NixOS systemd

621 Members
NixOS ❤️ systemd171 Servers

Load older messages


SenderMessageTime
31 Jan 2025
@qyliss:fairydust.spaceAlyssa Rosssystemd will make some14:41:04
@qyliss:fairydust.spaceAlyssa Rosslike /var/lib/machines and /var/lib/portables14:41:15
@elvishjerricco:matrix.orgElvishJerriccowait systemd just implicitly creates subvolumes?14:41:32
@qyliss:fairydust.spaceAlyssa RossIt comes with default tmpfiles.d rules that do14:41:41
@elvishjerricco:matrix.orgElvishJerriccohuh14:41:46
@elvishjerricco:matrix.orgElvishJerriccoodd14:41:48
@qyliss:fairydust.spaceAlyssa Rossit's very annoying because things will then fail if those paths are symlinks14:42:07
@qyliss:fairydust.spaceAlyssa Rossso they need to be bind mounts instead14:42:22
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)
  boot.initrd.systemd.services.rollback = {
    description = "Rollback BTRFS root subvolume to a pristine state";
    wantedBy = [ "initrd.target" ];
    after = [ "systemd-cryptsetup@crypted.service" ];
    before = [ "sysroot.mount" ];
    unitConfig.DefaultDependencies = "no";
    serviceConfig.Type = "oneshot";
    script = # bash
      ''
        mkdir /btrfs_tmp
        mount /dev/mapper/crypted /btrfs_tmp

        if [[ -e /btrfs_tmp/root ]]; then
          btrfs subvolume delete /btrfs_tmp/root
        fi

        btrfs subvolume create /btrfs_tmp/root
        umount /btrfs_tmp
      '';
  };

$ journalctl -b -u rollback
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: Starting Rollback BTRFS root subvolume to a pristine state...
جانفي 31 15:59:07 HP-14s-dq2024nf rollback-start[530]: ERROR: Could not destroy subvolume/snapshot: Directory not empty
جانفي 31 15:59:07 HP-14s-dq2024nf rollback-start[530]: Delete subvolume 324 (no-commit): '/btrfs_tmp/root'
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: rollback.service: Main process exited, code=exited, status=1/FAILURE
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: rollback.service: Failed with result 'exit-code'.
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: Failed to start Rollback BTRFS root subvolume to a pristine state.
15:00:41
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب) *
  boot.initrd.systemd.services.rollback = {
    description = "Rollback BTRFS root subvolume to a pristine state";
    wantedBy = [ "initrd.target" ];
    after = [ "systemd-cryptsetup@crypted.service" ];
    before = [ "sysroot.mount" ];
    unitConfig.DefaultDependencies = "no";
    serviceConfig.Type = "oneshot";
    script = # bash
      ''
        mkdir /btrfs_tmp
        mount /dev/mapper/crypted /btrfs_tmp

        if [[ -e /btrfs_tmp/root ]]; then
          btrfs subvolume delete /btrfs_tmp/root
        fi

        btrfs subvolume create /btrfs_tmp/root
        umount /btrfs_tmp
      '';
  };
$ journalctl -b -u rollback
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: Starting Rollback BTRFS root subvolume to a pristine state...
جانفي 31 15:59:07 HP-14s-dq2024nf rollback-start[530]: ERROR: Could not destroy subvolume/snapshot: Directory not empty
جانفي 31 15:59:07 HP-14s-dq2024nf rollback-start[530]: Delete subvolume 324 (no-commit): '/btrfs_tmp/root'
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: rollback.service: Main process exited, code=exited, status=1/FAILURE
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: rollback.service: Failed with result 'exit-code'.
جانفي 31 15:59:07 HP-14s-dq2024nf systemd[1]: Failed to start Rollback BTRFS root subvolume to a pristine state.
15:01:11
@elvishjerricco:matrix.orgElvishJerriccoyea, it seems like you've got subvolumes within that subvolume15:49:54
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)How did that happen?!15:50:31
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)
{
  disko.devices.disk.main = {
    type = "disk";
    device = "/dev/nvme0n1";
    content = {
      type = "gpt";
      partitions = {
        ESP = {
          size = "512M";
          type = "EF00";
          content = {
            type = "filesystem";
            format = "vfat";
            mountpoint = "/boot";
            mountOptions = [ "umask=0077" ];
          };
        };
        luks = {
          size = "100%";
          content = {
            type = "luks";
            name = "crypted";
            content = {
              type = "btrfs";
              extraArgs = [ "-f" ];
              subvolumes = {
                "/root" = {
                  mountpoint = "/";
                  mountOptions = [
                    "compress=zstd"
                    "noatime"
                  ];
                };
                "/nix" = {
                  mountpoint = "/nix";
                  mountOptions = [
                    "compress=zstd"
                    "noatime"
                  ];
                };
                "/swap" = {
                  mountpoint = "/.swapvol";
                  swap.swapfile.size = "7957M";
                };
              };
            };
          };
        };
      };
    };
  };
}

This is my disks setup.

15:50:51
@elvishjerricco:matrix.orgElvishJerriccoI mean, confirm whether I'm right or not first. But Alyssa did say systemd will auto-create subvolumes sometimes15:50:57
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Oh, I just realized, the swap15:51:14
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)I am so stupid15:51:29
@sigmasquadron:matrix.orgSigmaSquadronNot immediately realising an issue in a complicated computer setup doesn't make you stupid :)15:52:12
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Thanks15:52:38
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Can I delete the swapvol?15:52:46
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Would that break hibernation?15:52:54
@sigmasquadron:matrix.orgSigmaSquadronI guess you can delete it, delete the root subvolume, create the root subvolume, and create the swap subvolume in that service.15:53:34
@sigmasquadron:matrix.orgSigmaSquadronof course, don't forget to swapon/swapoff. It's a bit more imperative than disko or fileSystems.*, but it should always work.15:54:09
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)But won't this break hibernation?15:54:35
@sigmasquadron:matrix.orgSigmaSquadronI don't think it would, since the swap volume will still exist by the point you switch root and actually hibernate, but I don't use hibernation so I have no way to tell for certain.15:55:35
@elvishjerricco:matrix.orgElvishJerriccoit'll break hibernation unless you do it a little more carefully15:55:56
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Should I just make a swap partition?15:56:29
@elvishjerricco:matrix.orgElvishJerricco You need to order this service after systemd-hibernate-resume.service 15:56:35
@sigmasquadron:matrix.orgSigmaSquadronactually you really need a swap partition one way or the other.15:56:56
@sigmasquadron:matrix.orgSigmaSquadron
In reply to @nakibrayane:matrix.org
{
  disko.devices.disk.main = {
    type = "disk";
    device = "/dev/nvme0n1";
    content = {
      type = "gpt";
      partitions = {
        ESP = {
          size = "512M";
          type = "EF00";
          content = {
            type = "filesystem";
            format = "vfat";
            mountpoint = "/boot";
            mountOptions = [ "umask=0077" ];
          };
        };
        luks = {
          size = "100%";
          content = {
            type = "luks";
            name = "crypted";
            content = {
              type = "btrfs";
              extraArgs = [ "-f" ];
              subvolumes = {
                "/root" = {
                  mountpoint = "/";
                  mountOptions = [
                    "compress=zstd"
                    "noatime"
                  ];
                };
                "/nix" = {
                  mountpoint = "/nix";
                  mountOptions = [
                    "compress=zstd"
                    "noatime"
                  ];
                };
                "/swap" = {
                  mountpoint = "/.swapvol";
                  swap.swapfile.size = "7957M";
                };
              };
            };
          };
        };
      };
    };
  };
}

This is my disks setup.

CoW is enabled on that swap subvolume.
15:57:06
@elvishjerricco:matrix.orgElvishJerriccooh, yea, creating a swapfile on btrfs requires some care15:57:21

Show newer messages


Back to Room ListRoom Version: 6