I remember back in '99 when Brendon Davidson wrote:
> I installed linux on another hard drive yesterday and now I'm trying 
> to make a copy of the boot disk... problem is, when i try to copy the 
> disk to my hard drive, it gets to the /mnt/floppy/dev directory and 
> then actually copies /dev/hdb1 to the hard drive.  Needless to say, 
> this is not what I want.  It seems that on the disk they are block 
> special files.  Any help would be GREATLY appreciated.  Thanks.

Here's my best-effort partition copying command:

Assumes that
1) you are booted to the old drive, and all your files are in the /
   partition (that is, there are no other partitions used by linux
   that you want to copy like a distinct /usr or /var/spool)

2) your new drive is mounted under /mnt/new

        find / -xdev -depth | cpio -p -C 1048576 -d /mnt/new

The find generates a list of all files under / on the same
mount point (-xdev).  The -depth tells find to do a depth-first
search (hard to explain without using a big example, but
cpio needs it).

The cpio command does the actual copying.  -p is pass-through
mode (we're not creating or extracting from a cpio archive file, 
just using it to copy things).  -C 1048576 tells cpio to read
and write in 1MB blocks.  -d tells cpio to create directories if
it needs to.  /mnt/new is the target.

If you did have a seperate /usr partition or something you could do
this:

        find /usr -xdev -depth | cpio -p -C 1048576 -d /mnt/new/usr

I'll leave it as an excercise to the reader to conjure up a
script that parses the output of mount and does this all
automatically.  ;)

WARNING:  I've done this before, but I'm typing all this in
from memory and man pages..  I don't think there's any way to
really screw things up, but just watch out..  You might want
to add a -v to the cpio command to get it to print out what
it's doing.

                Matt

-- 
/* Matt Sayler -- [EMAIL PROTECTED] -- (512) 494-7360
   DO ABSTAIN FROM INTERCAL */
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to