!DBFhtjpqmJNENpLDOv:nixos.org

NixOS systemd

574 Members
NixOS ❤️ systemd158 Servers

Load older messages


SenderMessageTime
31 Jan 2025
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)Should I just make a swap partition?15:56:29
@elvishjerricco:matrix.org@elvishjerricco:matrix.org 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.org@elvishjerricco:matrix.orgoh, yea, creating a swapfile on btrfs requires some care15:57:21
@nakibrayane:matrix.orgRayane Nakib (ريّان نقيب)I don't know?!15:57:35
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgbut the btrfs command has a command that automatically does it correctly15:57:36
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgno 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.org@elvishjerricco:matrix.org 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.org@elvishjerricco:matrix.orgthat 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
@eyjhb:eyjhb.dkeyJhb* I added multi-user.target, and that seemed to work, but not sure if that's the correct way.08:00:49
@pederbs:pvv.ntnu.nopbsds changed their display name from pbsds to pbsds (FOSDEM).16:04:35
3 Feb 2025
@lorenzleutgeb:matrix.orgLorenz Leutgeb changed their display name from Lorenz Leutgeb 📞6343 to Lorenz Leutgeb.08:53:49
@matthewcroughan:defenestrate.itmatthewcroughan changed their display name from matthewcroughan (FOSDEM) to matthewcroughan.09:10:22

Show newer messages


Back to Room ListRoom Version: 6