prepare for ZFS
This commit is contained in:
parent
5606603533
commit
fc4607ec20
46
common.nix
46
common.nix
|
@ -25,8 +25,9 @@ in
|
|||
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||
system.stateVersion = "23.05"; # Did you read the comment?
|
||||
|
||||
# use the latest kernel
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
# use the latest kernel with ZFS support and enable that file system
|
||||
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
|
||||
# Use the systemd-boot EFI boot loader.
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
@ -38,18 +39,21 @@ in
|
|||
# we want to be able to do a memtest
|
||||
boot.loader.systemd-boot.memtest86.enable = true;
|
||||
|
||||
# use systemd early
|
||||
boot.initrd.systemd.enable = true;
|
||||
|
||||
# setup the console stuff early
|
||||
console.earlySetup = true;
|
||||
|
||||
# swap to RAM
|
||||
zramSwap.enable = true;
|
||||
|
||||
# root file system from encrypted disk
|
||||
# root file system in RAM
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/mapper/crypt-system";
|
||||
fsType = "btrfs";
|
||||
{ device = "none";
|
||||
fsType = "tmpfs";
|
||||
neededForBoot = true;
|
||||
options = [ "subvol=root" "noatime" "nodiratime" ];
|
||||
options = [ "defaults" "size=8G" "mode=755" ];
|
||||
};
|
||||
|
||||
# nix store file system from encrypted disk
|
||||
|
@ -95,32 +99,6 @@ in
|
|||
depends = [ "/data" ];
|
||||
};
|
||||
|
||||
# impermanence root setup
|
||||
boot.initrd.postDeviceCommands = pkgs.lib.mkAfter ''
|
||||
mkdir /btrfs_tmp
|
||||
mount /dev/mapper/crypt-system /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 +7); do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
|
||||
btrfs subvolume create /btrfs_tmp/root
|
||||
umount /btrfs_tmp
|
||||
'';
|
||||
|
||||
# keep some stuff persistent
|
||||
environment.persistence."/nix/persistent" = {
|
||||
hideMounts = true;
|
||||
|
@ -554,8 +532,8 @@ in
|
|||
# aliases
|
||||
shellAliases = {
|
||||
# system build/update/cleanup
|
||||
update = "sudo nixos-rebuild switch";
|
||||
upgrade = "sudo nixos-rebuild switch --upgrade";
|
||||
update = "sudo nixos-rebuild boot";
|
||||
upgrade = "sudo nixos-rebuild boot --upgrade";
|
||||
gc = "sudo nix-collect-garbage --delete-older-than 7d";
|
||||
verify = "sudo nix --extra-experimental-features nix-command store verify --all";
|
||||
optimize = "sudo nix --extra-experimental-features nix-command store optimise";
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
# amd graphics
|
||||
hardware.opengl.extraPackages = with pkgs; [ amdvlk rocm-opencl-icd rocm-opencl-runtime ];
|
||||
|
||||
# our hostname
|
||||
# our hostname and an ID for ZFS
|
||||
networking.hostName = "mini";
|
||||
networking.hostId = "e925ccfb";
|
||||
|
||||
# use NetworkManager
|
||||
networking.useDHCP = false;
|
||||
networking.networkmanager.enable = true;
|
||||
# classic dhcpcd
|
||||
networking.networkmanager.enable = false;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
# intel graphics
|
||||
hardware.opengl.extraPackages = with pkgs; [ intel-media-driver intel-compute-runtime ];
|
||||
|
||||
# our hostname
|
||||
# our hostname and an ID for ZFS
|
||||
networking.hostName = "neko";
|
||||
networking.hostId = "cf5a5ee6";
|
||||
|
||||
# use NetworkManager
|
||||
networking.useDHCP = false;
|
||||
networking.networkmanager.enable = true;
|
||||
# classic dhcpcd
|
||||
networking.networkmanager.enable = false;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
boot.initrd.kernelModules = [ "i915" ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
|
||||
# use the right soundcard
|
||||
boot.extraModprobeConfig = ''
|
||||
options snd_hda_intel enable=0,1
|
||||
'';
|
||||
|
||||
# don't check for split locks, for KVM and Co.
|
||||
boot.kernelParams = [ "split_lock_detect=off" ];
|
||||
|
||||
|
|
|
@ -21,6 +21,13 @@ nix --extra-experimental-features flakes --extra-experimental-features nix-comma
|
|||
|
||||
sudo dd if=result/iso/nixos-24.05.20240108.317484b-x86_64-linux.iso of=/dev/sda bs=4M conv=fsync
|
||||
|
||||
# good ZFS links
|
||||
|
||||
https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/Root%20on%20ZFS.html
|
||||
https://carjorvaz.com/posts/installing-nixos-with-root-on-tmpfs-and-encrypted-zfs-on-a-netcup-vps/
|
||||
https://astrid.tech/2021/12/17/0/two-disk-encrypted-zfs/
|
||||
https://mzhang.io/posts/2022-05-09-installing-nixos-on-encrypted-zfs/
|
||||
|
||||
#
|
||||
# enable ssh for root
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue