Python - Reading directly from hard drive

hard-drive, python

Solution

On linux, you can `open('/dev/sdX', 'r')`.

However, the easier way is using the `dd` commandline utility (but it will only work properly if both disks are exactly the same).

Problem

I want to read bytes directly off a hard drive, preferably using python. How can I do this, provided it is even possible. Also, can I write directly to a hard drive, and how? I want to do this to make a complete clone of a hard drive, and then restoring from that backup. I'm quite certain there are easier ways to get what I want done, and this is partly simply curiosity ;)

Original source