Skip to content

Commit

Permalink
distinguish between /dev/xxn0p1 and /dev/xxx1 naming
Browse files Browse the repository at this point in the history
nvme namespaces use special system, SATA SSDs just use /dev/sda1,2,...
  • Loading branch information
turtlebasket committed Nov 22, 2024
1 parent 4907d31 commit 560d926
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bootstrap/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 560d926

Please sign in to comment.