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()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.(Substitute your favorite blocksize for
1024k.)