Skip to Content.
Sympa Menu

baslinux - Re: [BL] hard drive resets during 'find'

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: 3aoo-cvfd AT dea.spamcon.org
  • To: baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] hard drive resets during 'find'
  • Date: Wed, 31 Dec 2003 14:03:58 +1300

Sindi Keesan wrote:
>
> > Yes, copying an entire filesystem from one drive to
> > another is possible (using tar). It is also possible
> > to ghost the entire drive (including DOS partition
> > and MBR) using dd.
>
> I just looked at tar --help and it does not mention anything
> about copying files between partitions or drives.

You pipe the output of tar -c to tar -x
------------------------------------------
#!/bin/bash
##copy a directory or partition
tar -C "$1" -cOl . | tar -C "$2" -xpf -
------------------------------------------
The first parameter ($1) is the source directory.
The second parametner ($2) is the target directory.

Note: if the target directory is mounted somewhere below
the source directory (eg. /mnt), you could end up with the
target directory (and its subdirectories) being included
in the copy (recursively). The cleanest way to do this
copy is from a third filesystem (eg. ramdisk BasicLinux).

If you are using the ramdisk BasicLinux to do the copy,
you could use the send/receive utility instead of the
above tar script. Although send/receive were designed
for use across a network, they can also be used on a single
system. Simply mount the source and target partitions, cd
to the target partition and execute:
-------
receive
-------
Then press ALT-F2 and login again. cd to the source partition
and execute:
----
send
----
When asked for the hostname of the target, enter: localhost

So, for example, to copy the entire filesystem from /dev/hda3
to /dev/hdb2:
(1) mke2fs /dev/hdb2
(2) mount /dev/hdb2 /hd
(3) cd /hd
(4) receive
(5) [second login]
(6) mount /dev/hda3 /mnt
(7) cd /mnt
(8) send
(9) localhost
(10) *

You may be wondering why we don't simply copy (cp) the filesystem
from the source partition to the target partition. The problem is
that a simple cp messes up the permissions and links. You can get
around this by using the -a parameter for cp, but I've still found
that links occasionally get fouled this way. The safests way to
handle such a transfer is via tar (which is what send/receive use).

> Are you suggesting that we archive/zip all the files into one
> large one on the other partition?

Yes, it can be done that way (and is probably best for newbies).
--------------------
cd /
tar -zcvf temp.tgz *
--------------------
That gives you a big temp.tgz file in /. Now mount the target
partition and cd to it.
-------------------
tar -zxvf /temp.tgz
-------------------
That will unzip the compressed filesystem to the target partition

With this method there is no risk of recursion (as long as you
don't mount the target partition until after temp.tgz has been
created). And, as a two-step process, it is easier to newbies
to sort out problems. As long as you have room on the source
partition for temp.tgz, this is the method I would recommend.

> really don't follow how you suggest copying all the linux
> files from hda3 to hdb.

They won't go to hdb. They will go to hdb1 or to hdb2 or to
hdb3 ...

> Is tar used instead of (DOS) xcopy?

cp is the closest equivalent of DOS xcopy. Feel free to use
it (with -a parameter), but don't be surprised if you get an
occasional link that wasn't carried over. Most experienced
Linux users prefer tar for this purpose.

> I don't think there is room on the linux partition that we
> have to copy all the files to a .tgz file on that partition.

Any partition (even DOS) will suffice for temp.tgz

Cheers,
Steven




Archive powered by MHonArc 2.6.24.

Top of Page