From 323d269a24fd7ef1b3be009ae3550b346d57c562 Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 10 Jan 2026 23:58:09 +0000 Subject: [PATCH] nixos/amazon: move nvme_core.io_timeout to runtime module This kernel parameter was accidentally added to the image builder module in 2018 (e4777ae2d84c) when it should have been in the runtime config. This causes a mismatch between AMIs built with the builder and systems configured with just the runtime module. Move it to modules/virtualisation/amazon-image.nix so that all EC2 instances get the recommended NVMe timeout, regardless of how they were provisioned. --- nixos/maintainers/scripts/ec2/amazon-image.nix | 11 ----------- nixos/modules/virtualisation/amazon-image.nix | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/nixos/maintainers/scripts/ec2/amazon-image.nix b/nixos/maintainers/scripts/ec2/amazon-image.nix index 9ce667a30995..e117b1d28d52 100644 --- a/nixos/maintainers/scripts/ec2/amazon-image.nix +++ b/nixos/maintainers/scripts/ec2/amazon-image.nix @@ -11,7 +11,6 @@ let mkOption optionalString types - versionAtLeast ; inherit (lib.options) literalExpression; cfg = config.amazonImage; @@ -46,16 +45,6 @@ in }) ]; - # Amazon recommends setting this to the highest possible value for a good EBS - # experience, which prior to 4.15 was 255. - # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#timeout-nvme-ebs-volumes - config.boot.kernelParams = - let - timeout = - if versionAtLeast config.boot.kernelPackages.kernel.version "4.15" then "4294967295" else "255"; - in - [ "nvme_core.io_timeout=${timeout}" ]; - options.amazonImage = { contents = mkOption { example = literalExpression '' diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix index 1e267bfdad95..640c81cff474 100644 --- a/nixos/modules/virtualisation/amazon-image.nix +++ b/nixos/modules/virtualisation/amazon-image.nix @@ -59,10 +59,19 @@ in ]; boot.initrd.kernelModules = [ "xen-blkfront" ]; boot.initrd.availableKernelModules = [ "nvme" ]; - boot.kernelParams = [ - "console=ttyS0,115200n8" - "random.trust_cpu=on" - ]; + boot.kernelParams = + let + # Amazon recommends setting this to the highest possible value for a good EBS + # experience, which prior to 4.15 was 255. + # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#timeout-nvme-ebs-volumes + nvmeTimeout = + if lib.versionAtLeast config.boot.kernelPackages.kernel.version "4.15" then "4294967295" else "255"; + in + [ + "console=ttyS0,115200n8" + "random.trust_cpu=on" + "nvme_core.io_timeout=${nvmeTimeout}" + ]; # Prevent the nouveau kernel module from being loaded, as it # interferes with the nvidia/nvidia-uvm modules needed for CUDA.