mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-06 21:17:14 -06:00
test: impermanence
This commit is contained in:
parent
34d40159cc
commit
4210004147
1 changed files with 10 additions and 10 deletions
|
|
@ -48,29 +48,29 @@ in
|
|||
};
|
||||
|
||||
boot.initrd.postResumeCommands = lib.mkAfter ''
|
||||
mkdir -p /mnt
|
||||
mount -o subvol=/ /dev/disk/by-label/root /mnt
|
||||
mkdir -p /btrfs_tmp
|
||||
mount -o subvol=/ /dev/disk/by-label/root /btrfs_tmp
|
||||
|
||||
if [[ -e /mnt/@ ]]; then
|
||||
mkdir -p /mnt/@old_roots
|
||||
timestamp=$(date --date="@$(stat -c %Y /mnt/@)" "+%Y-%m-%d_%H:%M:%S")
|
||||
mv /mnt/@ "/mnt/@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() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/mnt/$i"
|
||||
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
|
||||
for i in $(find /mnt/@old_roots/ -maxdepth 1 -mtime +30); do
|
||||
for i in $(find /btrfs_tmp/@old_roots/ -maxdepth 1 -mtime +30); do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
|
||||
btrfs subvolume create /mnt/@
|
||||
umount /mnt
|
||||
btrfs subvolume create /btrfs_tmp/@
|
||||
umount /btrfs_tmp
|
||||
'';
|
||||
|
||||
environment.persistence."/persistent" = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue