Skip to content

Commit 0917e43

Browse files
committed
Add support for nvme drives to clone tool
1 parent 61d2f57 commit 0917e43

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

rootfs/standard/usr/bin/clone_drive.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ def main():
7474

7575
# Detect Source and Target Drives
7676
mynode_drive = "not_found"
77+
mynode_partition = "not_found"
7778
mynode_found = False
7879
target_drive = "not_found"
80+
target_partition = "not_found"
7981
target_found = False
8082
both_drives_have_mynode = False
8183
for d in drives:
@@ -149,13 +151,21 @@ def main():
149151
# User asked for rescan, return, script will re-run right away
150152
if os.path.isfile("/tmp/.clone_rescan"):
151153
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"
152162

153163
# Setup for clone
154164
set_clone_state("in_progress")
155165
os.system(f"mkdir -p /tmp/drive1")
156166
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}")
159169

160170
# Update partitions (removes all + makes new without removing data)
161171
log_message("Formatting Drive...")
@@ -168,14 +178,14 @@ def main():
168178
# Make new partition on dest drive
169179
log_message("Creating Partition...")
170180
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)
172182
time.sleep(2)
173183

174184
# Mounting Partitions
175185
log_message("Mounting Partitions...")
176186
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)
179189

180190
# Clone drives
181191
os.system("echo 'Starting clone.' > /tmp/.clone_progress")

0 commit comments

Comments
 (0)