delet old btrfs root

This commit is contained in:
twoneis 2024-05-08 18:13:24 +02:00
parent a15c95f3a3
commit bfe077d474
2 changed files with 33 additions and 5 deletions

View file

@ -1,8 +1,36 @@
{ config, lib, ... }: { { config, lib, ... }: {
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; boot = {
boot.initrd.kernelModules = [ ]; initrd = {
boot.kernelModules = [ "kvm-amd" ]; availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
boot.extraModulePackages = [ ]; kernelModules = [ ];
postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/disk/by-uuid/b6e6bca7-1435-4b41-b174-8550eace7c32 /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"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
};
kernelModules = [ "kvm-amd" ];
extraModulePackages = [ ];
};
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {

View file

@ -39,7 +39,7 @@
}; };
modules = [ modules = [
./devices/ellaca ./devices/ellaca
] ++ clientModules; ] ++ clientModules;
}; };
# Surface Pro 7 (i5 128GB) # Surface Pro 7 (i5 128GB)