!DBFhtjpqmJNENpLDOv:nixos.org

NixOS systemd

620 Members
NixOS ❤️ systemd171 Servers

Load older messages


SenderMessageTime
31 Jan 2025
@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
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)I don't know?!15:57:35
@elvishjerricco:matrix.orgElvishJerriccobut the btrfs command has a command that automatically does it correctly15:57:36
@elvishjerricco:matrix.orgElvishJerriccono idea if disko does that correctly on its own or not15:58:05
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)

Would this do it?

after = [ "systemd-cryptsetup@crypted.service" "systemd-hibernate-resume.service" ];
15:58:27
@sigmasquadron:matrix.orgSigmaSquadronEasiest way is to have a swap partition.15:58:33
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Yeah, I will make a swap partition.15:58:54
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)I actually wasn't the swap subvol that is inside root, The subvols that are inside root are /root/srv and /root/var/something16:08:44
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب) * 16:09:04
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)And the swap subvol is outside the root subvol.16:09:34
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)How can I recursively remove subvols from root?16:09:49
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)

I figured it out:

  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

        delete_subvolume_recursively() {
          IFS=$'\n'
          for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
            delete_subvolume_recursively "/btrfs_tmp/$i"
          done
          btrfs subvolume delete "$1"
        }

        if [[ -e /btrfs_tmp/root ]]; then
          delete_subvolume_recursively /btrfs_tmp/root
        fi

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

16:39:19
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Thanks to everyone that help me :)16:39:31
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Now I would like to make a specialization named "no-rollback" that does not delete my root subvolume, This is useful in the case of a power loss I wouldn't need to get a recovery USB, I would just boot from the "no-rollback" options in my boot loader.16:41:13
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)* Thanks to everyone that helped me :)16:41:22
@ss:someonex.netSomeoneSerge (back on matrix) changed their display name from SomeoneSerge to SomeoneSerge (Bruxelles).19:34:52
1 Feb 2025
@elvishjerricco:matrix.orgElvishJerricco Sorry I missed this. Wow, nice job looking into it. So the problem IMO here is that we should probably mark our networking daemons to be reloaded instead of restarted. We should not be taking networking down during stc 03:16:06
@matthewcroughan:defenestrate.itmatthewcroughan changed their display name from matthewcroughan (already in Brussels) to matthewcroughan (FOSDEM).09:39:57
@eyjhb:eyjhb.dkeyJhb

I always have trouble setting a systemd unit up correctly. I want to have a systemd unit that will always run AFTER another unit has started, but I ALSO want it to run, if the unit itself has changed. E.g. I have unit called lldap, and I want to run lldapprovision. So when lldap starts -> run lldapprovision. When lldapprovision changes -> run lldapprovision. I have the following right now.

      wantedBy = [ config.systemd.services.lldap.name ];
      after = [ config.systemd.services.lldap.name ];

16:36:15
@eyjhb:eyjhb.dkeyJhbCurrently if I restart lldap, then lldapprovision will run. But changing e.g. the script in lldapprovision will not run lldapprovision16:52:36
2 Feb 2025
@elvishjerricco:matrix.orgElvishJerriccothat sounds like a complicated logic to add to switch-to-configuration, because of how it traverses units to figure out which ones should be started...03:42:09
@eyjhb:eyjhb.dkeyJhbI added multi-user.target, and that seemed to work07:30:03

Show newer messages


Back to Room ListRoom Version: 6