4

I am using dd command to copy disk drive /dev/sda on /dev/sdb. What I do is the following: I run

  1. dd if=/dev/sda of=/dev/sdb
  2. then mount /dev/sdb1 (note that /dev/sdb1 is not mounted on boot) to make sure that everything is there.

This works fine.

Then I make some changes on /dev/sda and try to copy the disk again. So I umount /dev/sdb and issue the same command (dd if=/dev/sda of=/dev/sdb).

After I mount /dev/sdb1 again the intermediate changes are not reflected on /dev/sdb and the state of /dev/sdb is the same as it was after the first mount of /dev/sdb1.

I am using ext3. Maybe the metadata gets corrupted or I just have to restart the system? Or maybe there is something to do with the journal. Could you please tell me what is causing the problem and how can I fix it?

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
nikozavar
  • 41
  • 1
  • 3
  • 1
    You are using `sdb` and `sdb1` interchangeably. Please check all occurrences of those to see that they're correct. Note also that you need to umount `/dev/sda[1]` (whatever you actually have mounted) to ensure that all filesystem updates actually have hit the disk. Copying a block device while it's still mounted is waiting for problems to happen... – wurtel Nov 05 '15 at 15:07
  • Yes, I know that having /dev/sda1 mounted while dd is executing is dangerous. But by the way is there any other way to ensure that all filesystem updates actually have hit the disk, besides from unmounting it or running sync. – nikozavar Nov 05 '15 at 16:32

1 Answers1

1

Judging by your question /dev/sda1 is a mounted disk and using dd in this manner will most likely get you a corrupted copy as dd doesn't properly handle writes in progress.

More information is here in an answer to a question on serverfault.

Fred Thomsen
  • 1,367
  • 1
  • 11
  • 16