@@ -74,8 +74,10 @@ def main():
74
74
75
75
# Detect Source and Target Drives
76
76
mynode_drive = "not_found"
77
+ mynode_partition = "not_found"
77
78
mynode_found = False
78
79
target_drive = "not_found"
80
+ target_partition = "not_found"
79
81
target_found = False
80
82
both_drives_have_mynode = False
81
83
for d in drives :
@@ -149,13 +151,21 @@ def main():
149
151
# User asked for rescan, return, script will re-run right away
150
152
if os .path .isfile ("/tmp/.clone_rescan" ):
151
153
return
154
+
155
+ # Calculate partitions
156
+ target_partition = f"{ target_drive } 1"
157
+ if "nvme" in target_drive :
158
+ target_partition = f"{ target_drive } p1"
159
+ mynode_partition = f"{ mynode_drive } 1"
160
+ if "nvme" in mynode_drive :
161
+ mynode_partition = f"{ mynode_drive } p1"
152
162
153
163
# Setup for clone
154
164
set_clone_state ("in_progress" )
155
165
os .system (f"mkdir -p /tmp/drive1" )
156
166
os .system (f"mkdir -p /tmp/drive2" )
157
- os .system (f"umount /dev/{ mynode_drive } 1 " )
158
- os .system (f"umount /dev/{ target_drive } 1 " )
167
+ os .system (f"umount /dev/{ mynode_partition } " )
168
+ os .system (f"umount /dev/{ target_partition } " )
159
169
160
170
# Update partitions (removes all + makes new without removing data)
161
171
log_message ("Formatting Drive..." )
@@ -168,14 +178,14 @@ def main():
168
178
# Make new partition on dest drive
169
179
log_message ("Creating Partition..." )
170
180
os .system ("echo 'Creating Partition...' > /tmp/.clone_progress" )
171
- subprocess .check_output (f"mkfs.ext4 -F -L MyNode /dev/{ target_drive } 1 " , shell = True )
181
+ subprocess .check_output (f"mkfs.ext4 -F -L MyNode /dev/{ target_partition } " , shell = True )
172
182
time .sleep (2 )
173
183
174
184
# Mounting Partitions
175
185
log_message ("Mounting Partitions..." )
176
186
os .system ("echo 'Mounting Partitions...' > /tmp/.clone_progress" )
177
- subprocess .check_output (f"mount /dev/{ mynode_drive } 1 /tmp/drive1" , shell = True )
178
- subprocess .check_output (f"mount /dev/{ target_drive } 1 /tmp/drive2" , shell = True )
187
+ subprocess .check_output (f"mount /dev/{ mynode_partition } /tmp/drive1" , shell = True )
188
+ subprocess .check_output (f"mount /dev/{ target_partition } /tmp/drive2" , shell = True )
179
189
180
190
# Clone drives
181
191
os .system ("echo 'Starting clone.' > /tmp/.clone_progress" )
0 commit comments