mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-11-21 22:03:19 +01:00
spin-down-hdd
This commit is contained in:
parent
a2c7be1bd3
commit
635796045f
@ -22,7 +22,7 @@
|
|||||||
../../modules/btrbk
|
../../modules/btrbk
|
||||||
./btrbk-config.nix
|
./btrbk-config.nix
|
||||||
../../modules/de-p1st-monitor.nix
|
../../modules/de-p1st-monitor.nix
|
||||||
#../../modules/spin-down.nix
|
#../../modules/spin-down-hdd.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
../../modules/btrfs-mount-options.nix
|
../../modules/btrfs-mount-options.nix
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
./btrbk-config.nix
|
./btrbk-config.nix
|
||||||
../../modules/netcup-dns.nix
|
../../modules/netcup-dns.nix
|
||||||
../../modules/de-p1st-monitor.nix
|
../../modules/de-p1st-monitor.nix
|
||||||
../../modules/spin-down.nix
|
../../modules/spin-down-hdd.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
../../modules/btrfs-mount-options.nix
|
../../modules/btrfs-mount-options.nix
|
||||||
@ -36,6 +36,14 @@
|
|||||||
boot.initrd.luks.devices."luks-3d974bd0-f373-469b-8e9c-2d5516e9f0f5".allowDiscards = true;
|
boot.initrd.luks.devices."luks-3d974bd0-f373-469b-8e9c-2d5516e9f0f5".allowDiscards = true;
|
||||||
yoda.btrfsFileSystems = ["/" "/mnt/data" "/mnt/backup"];
|
yoda.btrfsFileSystems = ["/" "/mnt/data" "/mnt/backup"];
|
||||||
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
||||||
|
yoda.spin-down-hdd = [
|
||||||
|
# 4tb1
|
||||||
|
"ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1"
|
||||||
|
# 3tb1
|
||||||
|
"ata-WDC_WD30EFRX-68EUZN0_WD-WCC4N1173157"
|
||||||
|
# 3tb2
|
||||||
|
"ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N0564095"
|
||||||
|
];
|
||||||
|
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
# Microarchitectural Data Sampling (MDS), see https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html#mitigation-control-on-the-kernel-command-line
|
# Microarchitectural Data Sampling (MDS), see https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html#mitigation-control-on-the-kernel-command-line
|
||||||
|
@ -10,22 +10,14 @@
|
|||||||
../../modules/headless.nix
|
../../modules/headless.nix
|
||||||
|
|
||||||
../../modules/ssh-fde-unlock.nix
|
../../modules/ssh-fde-unlock.nix
|
||||||
#../../modules/git.nix
|
|
||||||
../../modules/zsh.nix
|
../../modules/zsh.nix
|
||||||
#../../modules/ssh-client.nix
|
|
||||||
../../modules/ssh-server.nix
|
../../modules/ssh-server.nix
|
||||||
|
|
||||||
#../../modules/podman.nix
|
|
||||||
../../modules/docker.nix
|
../../modules/docker.nix
|
||||||
#../../modules/docker-pushrm.nix
|
|
||||||
|
|
||||||
../../modules/lid-switch-handling.nix
|
../../modules/lid-switch-handling.nix
|
||||||
../../modules/sendmail-mta.nix
|
../../modules/sendmail-mta.nix
|
||||||
../../modules/journalwatch.nix
|
../../modules/journalwatch.nix
|
||||||
|
|
||||||
#../../modules/btrbk
|
|
||||||
#../../modules/spin-down.nix
|
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
../../modules/btrfs-mount-options.nix
|
../../modules/btrfs-mount-options.nix
|
||||||
];
|
];
|
||||||
|
@ -35,8 +35,8 @@ in
|
|||||||
config = mkIf (length cfg > 0) {
|
config = mkIf (length cfg > 0) {
|
||||||
# For each element (e.g. "/") in `cfg` create this config:
|
# For each element (e.g. "/") in `cfg` create this config:
|
||||||
# fileSystems."/".options = [ "compress=zstd" "noatime" "commit=120" ];
|
# fileSystems."/".options = [ "compress=zstd" "noatime" "commit=120" ];
|
||||||
fileSystems = builtins.listToAttrs (builtins.map (fs: {
|
fileSystems = builtins.listToAttrs (builtins.map (btrfs_mount_path: {
|
||||||
name = fs;
|
name = btrfs_mount_path;
|
||||||
value = { options = [ "compress=zstd" "noatime" "commit=120" ]; };
|
value = { options = [ "compress=zstd" "noatime" "commit=120" ]; };
|
||||||
}) cfg);
|
}) cfg);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
{ config, pkgs, ... }:
|
|
||||||
|
|
||||||
# hdparm - get/set SATA/IDE device parameters
|
# hdparm - get/set SATA/IDE device parameters
|
||||||
# -q Handle the next option quietly, suppressing normal output (but not error messages).
|
# -q Handle the next option quietly, suppressing normal output (but not error messages).
|
||||||
# -I Print device information.
|
# -I Print device information.
|
||||||
@ -61,32 +59,45 @@
|
|||||||
# - The standby timeout has been set before already, otherwise it would be spinning.
|
# - The standby timeout has been set before already, otherwise it would be spinning.
|
||||||
# - Don't set the standby timeout again, as this will spin up the disk.
|
# - Don't set the standby timeout again, as this will spin up the disk.
|
||||||
|
|
||||||
|
{ lib, config, options, pkgs, modulesPath, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.yoda.spin-down-hdd;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
options = {
|
||||||
hdparm
|
yoda.spin-down-hdd = mkOption {
|
||||||
];
|
type = types.listOf types.str;
|
||||||
systemd.services."hdparm-4tb1" = {
|
default = [ ];
|
||||||
description = "Spin down inactive HDD";
|
example = ["ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1"];
|
||||||
wantedBy = [ "multi-user.target" ];
|
description = ''
|
||||||
serviceConfig.Type = "oneshot";
|
List with IDs (/dev/disk/by-id/<ID>) of HDDs to spin down after 10 minutes.
|
||||||
script = ''
|
'';
|
||||||
${pkgs.hdparm}/bin/hdparm -C /dev/disk/by-id/ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1 | ${pkgs.busybox}/bin/grep 'standby' || ${pkgs.hdparm}/bin/hdparm -S 24 /dev/disk/by-id/ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1
|
};
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
systemd.services."hdparm-3tb1" = {
|
|
||||||
description = "Spin down inactive HDD";
|
config = mkIf (length cfg > 0) {
|
||||||
wantedBy = [ "multi-user.target" ];
|
# TODO: Is this required or is it enough to use `${pkgs.hdparm}` in the systemd service script?
|
||||||
serviceConfig.Type = "oneshot";
|
environment.systemPackages = with pkgs; [
|
||||||
script = ''
|
hdparm
|
||||||
${pkgs.hdparm}/bin/hdparm -C /dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WCC4N1173157 | ${pkgs.busybox}/bin/grep 'standby' || ${pkgs.hdparm}/bin/hdparm -S 24 /dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WCC4N1173157
|
];
|
||||||
'';
|
|
||||||
};
|
# For each element (e.g. "ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1") in `cfg` create this config:
|
||||||
systemd.services."hdparm-3tb2" = {
|
# systemd.services."hdparm-ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0CPF0N1" = {
|
||||||
description = "Spin down inactive HDD";
|
# description = ...;
|
||||||
wantedBy = [ "multi-user.target" ];
|
# wantedBy = ...;
|
||||||
serviceConfig.Type = "oneshot";
|
# ...
|
||||||
script = ''
|
# };
|
||||||
${pkgs.hdparm}/bin/hdparm -C /dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N0564095 | ${pkgs.busybox}/bin/grep 'standby' || ${pkgs.hdparm}/bin/hdparm -S 24 /dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N0564095
|
systemd.services = builtins.listToAttrs (builtins.map (id: {
|
||||||
'';
|
name = "hdparm-${id}";
|
||||||
|
value = {
|
||||||
|
description = "Spin down inactive HDD";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
${pkgs.hdparm}/bin/hdparm -C /dev/disk/by-id/${id} | ${pkgs.busybox}/bin/grep 'standby' || ${pkgs.hdparm}/bin/hdparm -S 24 /dev/disk/by-id/${id}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}) cfg);
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user