[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dd or cp over network: should I use scp?



Hi!

On Thu, Feb 24, 2011 at 02:32:43PM +0200, Dotan Cohen wrote:
> I need to dd or cp my laptop's harddrive over the LAN. For a reason
> that I'd rather not get into I cannot remove the drive from the
> laptop.
> 
> Should I just use scp to copy over the LAN? Something like this?
> scp -r / root@178.63.65.136:/

Well... SSH has some overhead because it does encryption - you simply cannot
have encryption without _some_ overhead. 

I would recommend rsync instead - simply because if things go wrong during the
copy, it can pick up from where it left, rather than restarting from scratch:

	rsync -av --numeric-ids / root@otherhost:/

--numeric-ids is to ensure it uses the _numeric_ user/group IDS on the other
side. You may find that some users have differnt IDs between machines - e.g.
IDs that are added by packages (e.g. mysql and stuff).


> Can I actually use dd over the network, maybe by piping to scp
> somehow? What is the canonical way of doing this?
> Thanks!

Yes - if the disks are the same size, it's a no-brainer. My personal preference
for this is to use "nc" - which is lightweight, but does not do encryption.

On the "source" machine, send it out over the network
	sourcebox:~# dd if=/dev/sda | nc -l -p 9999

and on the destination box - which should be running a "live CD" or similar, as
blasting over a disk which is in use leads to kernel confusion and human
madness:
	destbox:~# nc $IP_OF_OTHER_BOX 9999 | dd of=/dev/sda

You may want to use gzip to trade off CPU usage for better network bandwith:

	sourcebox:~# dd if=/dev/sda | gzip | nc -l -p 9999
	destbox:~# nc $IP_OF_OTHER_BOX 9999 | gunzip | dd of=/dev/sda

Hope this helps
-- 
Karl E. Jorgensen


Reply to: