Using dd to transfer partition

R. Hirschfeld ray at unipay.nl
Tue Feb 8 04:24:17 MST 2005


> Date: Sun, 06 Feb 2005 15:11:55 -0800
> From: a monkey <the.only.monkey at gmail.com>
> 
> Now, dd is supposed to be able to transfer my linux partitions and their 
> contents over to another drive, correct? I just bought a brand new eMac 
> G4, and would like not to have to reinstall Linux on it. I want to just 
> transfer all of my linux partitions and there contents over to my new 
> eMac, in a snap. Does anybody know how I would do this? Any help 
> appreciated.

The problem with dd is that it works at a lower level than the
filesystem, so all the filesystem information (superblocks, filesystem
size, blocksize, bytes/inode ratio, etc.) gets transferred verbatim.
That's perfect if the two partitions are the same size, but if you
transfer into a larger partition then you'll end up with a smaller
filesystem within a larger partition.  It will work fine, but you
won't be able to access the extra space.  (At least this used to be
true of old Unix filesystems, I haven't dug into these details for a
long time so I'm not sure about Linux ext filesystems.)

What I usually do instead is something like:

cd from; tar cf - . | (cd to; tar xfBp -) &

where "from" and "to" are the mount points of the respective source
and destination partitions.  (If you have sufficient RAM you can speed
up the transfer by specifying a larger block size to tar.)

This can also be piped over a network if the disks are on different
machines.  In my experience this usually works better in the other
direction, e.g. (on the destination machine):

cd to; ssh -n user at host "cd from; tar cf - ." | tar xfBp - &

where "host" is the name of the source machine and "user" is your
login there.

A bonus of using tar is that the resulting filesystem will be
defragmented, whereas dd will transfer the holes along with the data.

I'm perhaps overly cautious, but I always do a diff -r after the
transfer before wiping the source.

Ray


More information about the yellowdog-general mailing list