test: impermanence

This commit is contained in:
Nick 2025-11-05 00:22:35 -06:00
parent 270275e225
commit ee6b51b2de

View file

@ -38,12 +38,12 @@ in
boot.initrd.postResumeCommands = lib.mkAfter ''
mkdir -p /btrfs_tmp
mount -o subvolid=5 /dev/disk/by-label/root /btrfs_tmp
mount -o subvol=/ /dev/disk/by-label/root /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
if [[ -e /btrfs_tmp/@ ]]; then
mkdir -p /btrfs_tmp/@old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/@)" "+%Y-%m-%d_%H:%M:%S")
mv /btrfs_tmp/@ "/btrfs_tmp/@old_roots/$timestamp"
fi
delete_subvolume_recursively() {
@ -54,11 +54,11 @@ in
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
for i in $(find /btrfs_tmp/@old_roots/ -maxdepth 1 -mtime +30 2>/dev/null); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
btrfs subvolume create /btrfs_tmp/@
umount /btrfs_tmp
'';