Subject: How to migrate a Debian system to another hard drive?

From: Tim Egbert <[email-masked]>
Date: Tue, 3 Sep 1996 07:20:51 -0600 (MDT)

Is there a simple way to migrate a Debian system to another hard drive?

On our Debian system, we have two hard drives.  The primary drive has the
root directory and swap partition and is bootable.  It also contains the
various Debian software packages, programs, libraries, etc.  The second
drive just has the /home directory tree. 

Our problem is that the primary drive is starting to make some "expensive
sounding noises" and may not last much longer.  We would like simply to
migrate the entire system to the second hard drive and disconnect the
first drive.  Is there an easy way to do this without reinstalling the
entire system and fixing up all the configuration files?

Thanks,

//  Tim Egbert
//  Bioengineering Lab, Anesthesiology Department
//  University of Utah Health Sciences Center

---

From: "David C. Winters" <[email-masked]>
Date: Tue, 3 Sep 1996 18:48:56 -0400 (EDT)

> entire system and fixing up all the configuration files?

	I've used dd() to essentially do the same thing, but only in cases
where the system partitions I've copied have been of the same size.  I'll
describe the situation I've used:

/dev/hd*1 is a 32-meg swap partition
/dev/hd*2 is a 815-meg ext2 partition
/dev/hd*3 is a 70?-meg partition for NT (currently unused)

	With the active partition being /dev/hda, I'll attach the target
drive as /dev/hdc, bring the system up, and execute 

    'dd if=/dev/hda2 of=/dev/hdc2' 

to do the copy.  Because the source partition is active when the duplication
is done, you'll need to "fisk" the target partition, a la

    'e2fsck /dev/hdc2' 

afterward.  I've shut the machine down, put /dev/hdc back into its own
machine as /dev/hda, bring it back up, and modify /etc/hostname,
/etc/init.d/network, and a number of other files to give the target machine
its own identity.  (Presumably, you won't have to change any files in this
manner.)  
	I don't know what would happen if the source and target partitions
aren't of the same size.  Some pretty nasty things are probably possible,
but all of my partitions were identical.

David [email-masked]
Office: 3503 WeH, x86720
MTFBWY

---

From: Joey Hess <[email-masked]>
Date: Tue, 3 Sep 1996 19:58:50 -0400 (EDT)

> entire system and fixing up all the configuration files?

My suggestion, since you already have the 2 drives on the machine, is to
use "cp -a -x" to copy all of / over to the other drive. Of course, the
second drive will be mounted somewhere, like /mnt. I believe that the -x
option will make cp ignore the second hard drive, and just copy the root
partition over. The -a will make it handle all the symlinks and special
files properly. I've done similar things with cp -a -x, and it always
worked fine. 

Of course, once you get it copies over, you'll need to make sure that lilo
is installed on the MBR (or whatever) of the second drive so you can boot
from it.

-- 
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj #  RSA-3-lines-perl
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1 #         Joey Hess
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)   # [email-masked]
               "true - do nothing, successfully" - - true (1)

---

From: [email-masked]
Date: Tue, 03 Sep 1996 20:45:10 -0400 (EDT)

>drive just has the /home directory tree. 
Tim,
This question of replicating a filesystem is one that comes up often.  I use
cpio to do this, and so far its been flawless for me.  It creates an exact 
duplicate of a filesystem, and the following command preserves file access
times, symlinks, etc.  Works nice, and its simple.  Just cd to the root of the
filesystem you wish to duplicate, and issues the following command:

# find . -depth | cpio -pdmv /target_directory

This is based on cpio's "pass thru" mode.  Everything appearing on stdin
goes to stdout....

Paul