@@ -29,16 +29,28 @@ def setup_disk(args):
2929 check_call (["parted" , "-a" , "optimal" , args .device , "mkpart" , "primary" , "512MB" , "100%" ])
3030 check_call (["parted" , "-a" , "optimal" , args .device , "set" , "1" , "esp" , "on" ])
3131
32+ # NOTE: nvme devices can have multiple namespaces, each with their own partitions,
33+ # use p1 and p2 for this case specifically - not true for SATA SSDs
34+
3235 print ("Creating filesystems..." )
33- check_call (["wipefs" , "-a" , f"{ args .device } p1" ])
34- check_call (["wipefs" , "-a" , f"{ args .device } p2" ])
36+ if args .device .startswith ("/dev/nvme" ):
37+ check_call (["wipefs" , "-a" , f"{ args .device } p1" ])
38+ check_call (["wipefs" , "-a" , f"{ args .device } p2" ])
39+ else :
40+ check_call (["wipefs" , "-a" , f"{ args .device } 1" ])
41+ check_call (["wipefs" , "-a" , f"{ args .device } 2" ])
3542 check_call (["mkfs.fat" , f"{ args .device } p1" , "-n" , "boot" ])
3643 check_call (["mkfs.ext4" , f"{ args .device } p2" , "-L" , "nixos" ])
3744
3845 print ("Mounting filesystems..." )
39- check_call (["mount" , f"{ args .device } p2" , "/mnt" ])
40- check_call (["mkdir" , "-p" , "/mnt/boot" ])
41- check_call (["mount" , f"{ args .device } p1" , "/mnt/boot" ])
46+ if args .device .startswith ("/dev/nvme" ):
47+ check_call (["mount" , f"{ args .device } p2" , "/mnt" ])
48+ check_call (["mkdir" , "-p" , "/mnt/boot" ])
49+ check_call (["mount" , f"{ args .device } p1" , "/mnt/boot" ])
50+ else :
51+ check_call (["mount" , f"{ args .device } 1" , "/mnt" ])
52+ check_call (["mkdir" , "-p" , "/mnt/boot" ])
53+ check_call (["mount" , f"{ args .device } 2" , "/mnt/boot" ])
4254
4355
4456def get_iface (args ):
0 commit comments