| 31 Jan 2025 |
ElvishJerricco | sidenote, the impermanence readme really ought to include a solid systemd initrd example. | 14:36:32 |
Alyssa Ross | https://git.qyliss.net/nixlib/tree/sys/mbp.nix#n18 | 14:37:27 |
Rayane Nakib (ريّان نقيب) | In reply to @elvishjerricco:matrix.org sidenote, the impermanence readme really ought to include a solid systemd initrd example. And an option to just delete the old root, or keep only one version, I have limited space im my laptop, I can't have 30 days old files there. | 14:37:42 |
Alyssa Ross | Being able to remove a directory without being able to recurse is to me the main appeal of subvolems | 14:38:23 |
Alyssa Ross | * | 14:38:28 |
Rayane Nakib (ريّان نقيب) | In reply to @qyliss:fairydust.space Being able to remove a directory without being able to recurse is to me the main appeal of subvolumes I couldn't make it work. | 14:38:59 |
ElvishJerricco | (sidenote, update that to postResumeCommands rather than postDeviceCommands, if you care at all about not having horrible breakage if you use hibernation) | 14:39:08 |
Alyssa Ross | I don't use hybernation, but that sounds like a good change to make regardless, thank you. | 14:40:39 |
Alyssa Ross | In reply to @nakibrayane:matrix.org I couldn't make it work. You don't have nested subvolumes in there, do you? | 14:41:01 |
Alyssa Ross | systemd will make some | 14:41:04 |
Alyssa Ross | like /var/lib/machines and /var/lib/portables | 14:41:15 |
ElvishJerricco | wait systemd just implicitly creates subvolumes? | 14:41:32 |
Alyssa Ross | It comes with default tmpfiles.d rules that do | 14:41:41 |
ElvishJerricco | huh | 14:41:46 |
ElvishJerricco | odd | 14:41:48 |
Alyssa Ross | it's very annoying because things will then fail if those paths are symlinks | 14:42:07 |
Alyssa Ross | so they need to be bind mounts instead | 14:42:22 |
Rayane 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 |
Rayane 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 | yea, it seems like you've got subvolumes within that subvolume | 15:49:54 |
Rayane Nakib (ريّان نقيب) | How did that happen?! | 15:50:31 |
Rayane 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 | I mean, confirm whether I'm right or not first. But Alyssa did say systemd will auto-create subvolumes sometimes | 15:50:57 |
Rayane Nakib (ريّان نقيب) | Oh, I just realized, the swap | 15:51:14 |
Rayane Nakib (ريّان نقيب) | I am so stupid | 15:51:29 |
SigmaSquadron | Not immediately realising an issue in a complicated computer setup doesn't make you stupid :) | 15:52:12 |
Rayane Nakib (ريّان نقيب) | Thanks | 15:52:38 |
Rayane Nakib (ريّان نقيب) | Can I delete the swapvol? | 15:52:46 |
Rayane Nakib (ريّان نقيب) | Would that break hibernation? | 15:52:54 |
SigmaSquadron | I guess you can delete it, delete the root subvolume, create the root subvolume, and create the swap subvolume in that service. | 15:53:34 |