@@ -29,16 +29,28 @@ def setup_disk(args):
29
29
check_call (["parted" , "-a" , "optimal" , args .device , "mkpart" , "primary" , "512MB" , "100%" ])
30
30
check_call (["parted" , "-a" , "optimal" , args .device , "set" , "1" , "esp" , "on" ])
31
31
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
+
32
35
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" ])
35
42
check_call (["mkfs.fat" , f"{ args .device } p1" , "-n" , "boot" ])
36
43
check_call (["mkfs.ext4" , f"{ args .device } p2" , "-L" , "nixos" ])
37
44
38
45
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" ])
42
54
43
55
44
56
def get_iface (args ):
0 commit comments