attempting impermanence on testbed machine

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-11-26 14:57:29 -06:00
parent 35589dad72
commit e90513a890
6 changed files with 353 additions and 29 deletions

View file

@ -69,6 +69,7 @@ nixos-generate-config --root /mnt
# @swap options + "noatime"
# @snapshots options + "compress=zstd" "noatime"
# @persist options + "compress=zstd"
# + neededForBoot = true;
# add Swap device
swapDevices = [{
@ -132,6 +133,36 @@ In hardware-configuration ensure these are all added:
};
```
### Impermanence BTRFS setup (optional)
```hardware-configuration.nix
boot.initrd.postResumeCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/ROOT_FILESYSTEM /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
'';
```
### Install nixos
`sudo nixos-install`