[lug] Moving / partition to a new disk

Dean Brissinger Dean.Brissinger at vexcel.com
Mon Dec 13 11:11:49 MST 2004

On Fri, 2004-12-10 at 15:30 -0700, D. Stimits wrote:
> Michael Kahn wrote:
> > I wish to transfer an entire / directory structure from
> > a partition on an old disk drive to a new partition on
> > a new disk drive.

> Using cpio means proper copy of everything, even device special files. 
> Never use cp for a backup. Imagine the chaos of trying to cp -a /dev/*, 
> and reading and copying /dev/random :P
> Like this:
> find /SomeSource -print -xdev | cpio -pdm SomeDestination

If you change your partitioning be sure to update /etc/fstab before you
boot!  :-)  And of course, don't forget to install your boot loader on
the new disk.

Using find + cpio is the most compatible method if you are crossing file
system types (say ext2 to ext3).  It also is good if you are moving to a
difference size partition.  The cpio trick works over NFS, different
file systems, and on other flavors of UNIX.

If the two partitions are the same size and you want the filesystem
intact you can copy the device file to the new device file.  Say you're
using partition 1 on devices hda and hdb:

        cp /dev/hda1 /dev/hdb1

This is the same as dd if=/dev/hda1 of=/dev/hdb1 ...  Most new versions
of cp will do the right thing on Linux.

dump | restore is an old-school method of doing this.  However since
Linus has declared dump and friends as obsolete I don't suggest
continuing to rely on them unless you have to.  SuSE and other distros
are starting to ship it as part of a non-standard install.  

More information about the LUG mailing list