From 294789d9bbc05b6d0cddea472841afee2366a691 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 8 Apr 2024 01:44:48 +0200 Subject: [PATCH] Explain why we use recursive deletion --- system/impermanence/autowipe.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/impermanence/autowipe.nix b/system/impermanence/autowipe.nix index e4e228d..f0ba6a5 100644 --- a/system/impermanence/autowipe.nix +++ b/system/impermanence/autowipe.nix @@ -34,6 +34,18 @@ in umount /mnt ''; in '' + # Simply deleting a subvolume with btrfs subvolume delete will not work, + # if that subvolume contains other btrfs subvolumes. Because of that, we + # instead use this function to delete subvolumes, whihc will first perform + # a recursive deletion of any nested subvolumes. + # + # This is necessary, because the root subvolume will actually usually contain + # other subvolumes, even if the user haven't created those explicitly. It seems + # that NixOS creates these automatically. Namely, I observed these in root subvol: + # - root/srv + # - root/var/lib/portables + # - root/var/lib/machines + # - root/var/tmp delete_subvolume_recursively() { IFS=$'\n' for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do