From ce6e0f69af06485256ffb3e802e9284582ef5cb3 Mon Sep 17 00:00:00 2001 From: Julien Malka Date: Sat, 26 Apr 2025 12:56:41 +0200 Subject: [PATCH] chore: move gustave to ext4 --- machines/gustave/disko.nix | 80 +++++++++++++++++++++++------------ machines/gustave/hardware.nix | 38 ++++++----------- 2 files changed, 65 insertions(+), 53 deletions(-) diff --git a/machines/gustave/disko.nix b/machines/gustave/disko.nix index 8be9924..ebe567d 100644 --- a/machines/gustave/disko.nix +++ b/machines/gustave/disko.nix @@ -1,17 +1,18 @@ { devices = { disk = { - sda = { + main = { type = "disk"; - device = "/dev/sda"; + device = "/dev/sdb"; content = { type = "gpt"; partitions = { + boot = { + size = "1M"; + type = "EF02"; + }; ESP = { - priority = 1; - name = "ESP"; - start = "1M"; - end = "128M"; + size = "512M"; type = "EF00"; content = { type = "filesystem"; @@ -19,35 +20,60 @@ mountpoint = "/boot"; }; }; + swap = { + size = "16G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; root = { size = "100%"; content = { - type = "btrfs"; - extraArgs = [ "-f" ]; # Override existing partition - # Subvolumes must set a mountpoint in order to be mounted, - # unless their parent is mounted - subvolumes = { - # Subvolume name is different from mountpoint - "/root" = { - mountpoint = "/"; - }; - # Subvolume name is the same as the mountpoint - "/persistent" = { - mountpoint = "/persistent"; - }; - "/nix" = { - mountOptions = [ - "compress=zstd" - "noatime" - ]; - mountpoint = "/nix"; - }; - }; + type = "lvm_pv"; + vg = "mainpool"; }; }; }; }; }; }; + lvm_vg = { + mainpool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ "defaults" ]; + }; + }; + persistent = { + size = "1500G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/persistent"; + mountOptions = [ "defaults" ]; + }; + }; + + store = { + size = "200G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/nix"; + }; + }; + }; + }; + }; }; } diff --git a/machines/gustave/hardware.nix b/machines/gustave/hardware.nix index a383bfe..dd6472f 100644 --- a/machines/gustave/hardware.nix +++ b/machines/gustave/hardware.nix @@ -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";