Reputation: 681
Can I clone sda
to sdb
with this Python program?
filein = open('/dev/sda', 'rb')
fileout = open('/dev/sdb', 'wb')
while True:
tmp = filein.read(100000)
fileout.write(tmp)
filein.close()
fileout.close()
Upvotes: 1
Views: 277
Reputation: 21329
Your script will not work entirely, no. For instance, how will you exit from the loop on EOF?
But more to the point, why use Python for this task? Why not dd
? It already handles all the cases you would need to deal with for this task.
dd if=/dev/sda of=/dev/sdb bs=1024k
(Substitute your favorite blocksize for 1024k
.)
Upvotes: 3