diff --git a/final/configuration.nix b/final/configuration.nix index 3248d68..0bfe35d 100644 --- a/final/configuration.nix +++ b/final/configuration.nix @@ -30,6 +30,13 @@ delete_subvolume_recursively() { IFS=$'\n' + + # If we accidentally end up with a file or directory under old_roots, + # the code will enumerate all subvolumes under the main volume. + # We don't want to remove everything under true main volume. Only + # proceed if this path is a btrfs subvolume (inode=256). + if [ $(stat -c %i "$1") -ne 256 ]; then return; fi + for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do delete_subvolume_recursively "/btrfs_tmp/$i" done