dd cloing active disk.. safe?

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
Hello chaps and chappettes.. I wish to clone the currently operational disk. I've used dd many times before, and am confident with it, but this disk is utterly important, so I wanted to check that using dd on it, in the form of:
Code:
# dd if=/dev/hda of=/dev/hdb
is not going to cause me any problems. /dev/hda is the disk that my gentoo install is running from. I.e. it has the /boot partition with the currently active kernel, and the swap partition that is currently in use.

Should I be wary?
 
It's 'safe', as in it will not affect the currently running system, but any mounted filesystems will not be copied correctly if they are modified whilst the dd is running (very likely)

I'd instead partition the destination disk exactly the same (sfdisk -d /dev/hda | sfdisk /dev/hdb), make filesystems on the destination, and rsync the files. You get a free defrag that way, too ;)

If you absolutely need to do a block copy, boot into livecd or into single user mode with read-only filesystems ("<kernel> single ro" in your bootloader) and dd from there.

Also, dd will be extraordinarily slow unless you use a larger block size, eg "bs=1M"
 
Last edited:
reading is fine, writing to a drive your currently booted off is a nono and should be done from live cd.. writing to a drive your not using is fine!
 
Back
Top Bottom