Something went wrong on my machine and /dev/loop8p2 was not present,
even though loop8 and loop8p1 were. (I think the loopback device was
mounted somewhere and the kernel wouldn't reread the partition table.)
Since we are running as root, we can easily create a new file in /dev.
Let's avoid this.
else:
dev = None
+ path = dev if dev is not None else partition(loopdev, partno)
try:
- run(["dd", "if=" + blob.name, "of=" + (dev if dev is not None else partition(loopdev, partno))], check=True)
+ run(['dd', f'if={blob.name}', f'of={path}', 'conv=nocreat'], check=True)
finally:
luks_close(dev, "Closing LUKS root partition")