| 31 Jan 2025 |
SigmaSquadron | of 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 |
Rayane Nakib (ريّان نقيب) | But won't this break hibernation? | 15:54:35 |
SigmaSquadron | I 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 | it'll break hibernation unless you do it a little more carefully | 15:55:56 |
Rayane Nakib (ريّان نقيب) | Should I just make a swap partition? | 15:56:29 |
ElvishJerricco | You need to order this service after systemd-hibernate-resume.service | 15:56:35 |
SigmaSquadron | actually you really need a swap partition one way or the other. | 15:56:56 |
SigmaSquadron | 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 | oh, yea, creating a swapfile on btrfs requires some care | 15:57:21 |
Rayane Nakib (ريّان نقيب) | I don't know?! | 15:57:35 |
ElvishJerricco | but the btrfs command has a command that automatically does it correctly | 15:57:36 |
ElvishJerricco | no idea if disko does that correctly on its own or not | 15:58:05 |
Rayane Nakib (ريّان نقيب) | Would this do it?
after = [ "systemd-cryptsetup@crypted.service" "systemd-hibernate-resume.service" ];
| 15:58:27 |
SigmaSquadron | Easiest way is to have a swap partition. | 15:58:33 |
Rayane Nakib (ريّان نقيب) | Yeah, I will make a swap partition. | 15:58:54 |
Rayane Nakib (ريّان نقيب) | I actually wasn't the swap subvol that is inside root, The subvols that are inside root are /root/srv and /root/var/something | 16:08:44 |
Rayane Nakib (ريّان نقيب) | * | 16:09:04 |
Rayane Nakib (ريّان نقيب) | And the swap subvol is outside the root subvol. | 16:09:34 |
Rayane Nakib (ريّان نقيب) | How can I recursively remove subvols from root? | 16:09:49 |
Rayane 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 |
Rayane Nakib (ريّان نقيب) | Thanks to everyone that help me :) | 16:39:31 |
Rayane 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 |
Rayane Nakib (ريّان نقيب) | * Thanks to everyone that helped me :) | 16:41:22 |
| SomeoneSerge (back on matrix) changed their display name from SomeoneSerge to SomeoneSerge (Bruxelles). | 19:34:52 |
| 1 Feb 2025 |
ElvishJerricco | 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 changed their display name from matthewcroughan (already in Brussels) to matthewcroughan (FOSDEM). | 09:39:57 |
eyJhb | 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 | Currently if I restart lldap, then lldapprovision will run. But changing e.g. the script in lldapprovision will not run lldapprovision | 16:52:36 |
| 2 Feb 2025 |
ElvishJerricco | that 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 | I added multi-user.target, and that seemed to work | 07:30:03 |