chore: move gustave to ext4

This commit is contained in:
Luj 2025-04-26 12:56:41 +02:00
parent 2d68129ec8
commit ce6e0f69af
Signed by: luj
GPG key ID: 6FC74C847011FD83
2 changed files with 65 additions and 53 deletions

View file

@ -1,4 +1,9 @@
{ lib, modulesPath, ... }:
{
lib,
modulesPath,
pkgs,
...
}:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
@ -15,33 +20,14 @@
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/persistent".neededForBoot = lib.mkForce true;
boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/disk/by-partlabel/disk-sda-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"
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
boot.initrd.postDeviceCommands = ''
lvm lvremove --force /dev/mainpool/root || :
yes | lvm lvcreate --size 100G --name root mainpool
${pkgs.e2fsprogs}/bin/mkfs.ext4 /dev/mainpool/root
'';
fileSystems."/persistent".neededForBoot = lib.mkForce true;
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";