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,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";
};
};
};
};
};
};
}

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";