From 560d926b379ebbaf7c7d16d6a6cf9011a1dd69f9 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Thu, 21 Nov 2024 18:35:59 -0800 Subject: [PATCH] distinguish between /dev/xxn0p1 and /dev/xxx1 naming nvme namespaces use special system, SATA SSDs just use /dev/sda1,2,... --- bootstrap/bootstrap | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap index 561c20a..02e704b 100755 --- a/bootstrap/bootstrap +++ b/bootstrap/bootstrap @@ -29,16 +29,28 @@ def setup_disk(args): check_call(["parted", "-a", "optimal", args.device, "mkpart", "primary", "512MB", "100%"]) check_call(["parted", "-a", "optimal", args.device, "set", "1", "esp", "on"]) + # NOTE: nvme devices can have multiple namespaces, each with their own partitions, + # use p1 and p2 for this case specifically - not true for SATA SSDs + print("Creating filesystems...") - check_call(["wipefs", "-a", f"{args.device}p1"]) - check_call(["wipefs", "-a", f"{args.device}p2"]) + if args.device.startswith("/dev/nvme"): + check_call(["wipefs", "-a", f"{args.device}p1"]) + check_call(["wipefs", "-a", f"{args.device}p2"]) + else: + check_call(["wipefs", "-a", f"{args.device}1"]) + check_call(["wipefs", "-a", f"{args.device}2"]) check_call(["mkfs.fat", f"{args.device}p1", "-n", "boot"]) check_call(["mkfs.ext4", f"{args.device}p2", "-L", "nixos"]) print("Mounting filesystems...") - check_call(["mount", f"{args.device}p2", "/mnt"]) - check_call(["mkdir", "-p", "/mnt/boot"]) - check_call(["mount", f"{args.device}p1", "/mnt/boot"]) + if args.device.startswith("/dev/nvme"): + check_call(["mount", f"{args.device}p2", "/mnt"]) + check_call(["mkdir", "-p", "/mnt/boot"]) + check_call(["mount", f"{args.device}p1", "/mnt/boot"]) + else: + check_call(["mount", f"{args.device}1", "/mnt"]) + check_call(["mkdir", "-p", "/mnt/boot"]) + check_call(["mount", f"{args.device}2", "/mnt/boot"]) def get_iface(args):