mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-06-08 02:09:04 +02:00
chore: move gustave to ext4
This commit is contained in:
parent
2d68129ec8
commit
ce6e0f69af
2 changed files with 65 additions and 53 deletions
|
@ -1,17 +1,18 @@
|
||||||
{
|
{
|
||||||
devices = {
|
devices = {
|
||||||
disk = {
|
disk = {
|
||||||
sda = {
|
main = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
device = "/dev/sda";
|
device = "/dev/sdb";
|
||||||
content = {
|
content = {
|
||||||
type = "gpt";
|
type = "gpt";
|
||||||
partitions = {
|
partitions = {
|
||||||
|
boot = {
|
||||||
|
size = "1M";
|
||||||
|
type = "EF02";
|
||||||
|
};
|
||||||
ESP = {
|
ESP = {
|
||||||
priority = 1;
|
size = "512M";
|
||||||
name = "ESP";
|
|
||||||
start = "1M";
|
|
||||||
end = "128M";
|
|
||||||
type = "EF00";
|
type = "EF00";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
|
@ -19,27 +20,55 @@
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
swap = {
|
||||||
|
size = "16G";
|
||||||
|
content = {
|
||||||
|
type = "swap";
|
||||||
|
discardPolicy = "both";
|
||||||
|
};
|
||||||
|
};
|
||||||
root = {
|
root = {
|
||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "btrfs";
|
type = "lvm_pv";
|
||||||
extraArgs = [ "-f" ]; # Override existing partition
|
vg = "mainpool";
|
||||||
# Subvolumes must set a mountpoint in order to be mounted,
|
};
|
||||||
# unless their parent is mounted
|
};
|
||||||
subvolumes = {
|
};
|
||||||
# Subvolume name is different from mountpoint
|
};
|
||||||
"/root" = {
|
};
|
||||||
|
};
|
||||||
|
lvm_vg = {
|
||||||
|
mainpool = {
|
||||||
|
type = "lvm_vg";
|
||||||
|
lvs = {
|
||||||
|
root = {
|
||||||
|
size = "100G";
|
||||||
|
pool = "mainpool";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
mountpoint = "/";
|
mountpoint = "/";
|
||||||
|
mountOptions = [ "defaults" ];
|
||||||
};
|
};
|
||||||
# Subvolume name is the same as the mountpoint
|
};
|
||||||
"/persistent" = {
|
persistent = {
|
||||||
|
size = "1500G";
|
||||||
|
pool = "mainpool";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
mountpoint = "/persistent";
|
mountpoint = "/persistent";
|
||||||
|
mountOptions = [ "defaults" ];
|
||||||
};
|
};
|
||||||
"/nix" = {
|
};
|
||||||
mountOptions = [
|
|
||||||
"compress=zstd"
|
store = {
|
||||||
"noatime"
|
size = "200G";
|
||||||
];
|
pool = "mainpool";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
mountpoint = "/nix";
|
mountpoint = "/nix";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -47,7 +76,4 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
{ lib, modulesPath, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
||||||
|
@ -15,33 +20,14 @@
|
||||||
boot.kernelModules = [ ];
|
boot.kernelModules = [ ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
fileSystems."/persistent".neededForBoot = lib.mkForce true;
|
boot.initrd.postDeviceCommands = ''
|
||||||
|
lvm lvremove --force /dev/mainpool/root || :
|
||||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
yes | lvm lvcreate --size 100G --name root mainpool
|
||||||
mkdir /btrfs_tmp
|
${pkgs.e2fsprogs}/bin/mkfs.ext4 /dev/mainpool/root
|
||||||
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
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
fileSystems."/persistent".neededForBoot = lib.mkForce true;
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue