0
I have two hard disks with the same sizes - represented as /dev/sda and /dev/sdb. I am trying to copy /dev/sda on /dev/sdb. /dev/sda has one ext3 partition. /dev/sda and /dev/sdb have the same partition layout. What I do is use the following command:
dd if=/dev/sda of=/dev/sdb
When I mount the file system on /dev/sdb I see that not all of the changes are reflected on the device. In other words the disks are not the same. So it fails. And I don't seem to figure out why. Can this corrupt the partition table on /dev/sdb. Is this the proper way to clone a disk?
Well, I don't unmount the file system on /dev/sda before I start cloning it. But I am absolutely sure that nobody is writing on it while the cloning is executing.
Actually, what you can be sure of is tht someone is wirting on /dev/sda, not viceversa. Linux has a zillion services logging all sorts of real-time info which are not under your control, and which you should leave well nigh alone. The proper way to clone the disk is the one you are using, but with both disks unmounted. Your current operation is also dangerous for /dev/sda. You ought to read this Arch Linux Wiki page, https://wiki.archlinux.org/index.php/Disk_cloning#Create_disk_image, where it says: Make sure no partitions are mounted from the source hard drive.
– MariusMatutiae – 2015-11-06T07:21:18.847@MariusMatutiae why it is dangerous to /dev/sda? – ilkhd – 2015-11-06T09:47:09.187
Because inode info may change after dd has copied the indoe, leaving the info in inode obsolete, parts of a file unaccounted for, and so on. – MariusMatutiae – 2015-11-06T10:10:03.757
@MariusMatutiae dd does not lock the file while reading, or I am wrong? – ilkhd – 2015-11-06T19:08:33.800