From f10bead8fd068f2cb82cbdc1a938a67bd967974c Mon Sep 17 00:00:00 2001 From: cransom user Date: Tue, 2 Feb 2016 01:40:41 +0000 Subject: [PATCH] Do not relocate /nix and /tmp to small disks on AWS The default behavior with an m3.medium instance is to relocate /nix and /tmp to /disk0 because an assumption is made that any ephemeral disk is larger than the root volume. Rather than make that assumption, add a check to see if the disk is larger, and only then relocate /nix and /tmp. This addresses https://github.com/NixOS/nixpkgs/issues/12613 --- nixos/modules/virtualisation/amazon-image.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix index 7ccc9df740e..7cb37bbc4a7 100644 --- a/nixos/modules/virtualisation/amazon-image.nix +++ b/nixos/modules/virtualisation/amazon-image.nix @@ -68,7 +68,11 @@ let cfg = config.ec2; in diskNr=$((diskNr + 1)) echo "mounting $device on $mp..." if mountFS "$device" "$mp" "" ext3; then - if [ -z "$diskForUnionfs" ]; then diskForUnionfs="$mp"; fi + if [ -z "$diskForUnionfs" -a \ + $(lsblk -bno size $device) -gt $(lsblk -bno size /dev/xvda1) + ]; then + diskForUnionfs="$mp"; + fi fi else echo "skipping unknown device type $device"