dslreports logo
 
    All Forums Hot Topics Gallery
spc
uniqs
120

benyto
Premium Member
join:2000-07-09
Chico, CA

3 recommendations

benyto to bluesea1

Premium Member

to bluesea1

Re: norton ghost in linux?

I'm going to add another bit of information to this thread. Today I wanted to transfer the data from my desktop hard drive to another hard drive. I wanted to do this for two reasons: 1) I was running a bit shy on free space on the five gig partition; 2) It allows me to compare the exact same install on two different systems simultaneously.

Here's how I did it:

First, I removed the 20 gig hard drive out of one of my computers and plugged it in to my current desktop. I then wiped what were the /boot and / partitions on this drive by running mke2fs. Once that was finished I mounted what was going to be the / partition (/dev/hdd3) in /mnt. I changed to the / directory on my desktop drive and issued this command:

# tar -cplP -X tar_ignore -f - . | (cd /mnt; tar xf -)

What's happening with this command?

Just about everything before the pipe is the same as in my previous example. This time, however, I removed /dev from my tar_ignore file. If you don't copy over the /dev directory you won't be able to boot properly. The file that is being created is a dash (-). This option causes tar to write the information to standard output rather than to a file. This allows us to pipe it to another command. The parentheses after the pipe open up a new shell and run the commands within it. First, we change to the /mnt directory (where the / partition of the new hard drive is mounted). Then we use tar to extract a file, which is also a single slash. In the case of extraction, tar grabs information from the standard input. In this case it is extracting the stream that we sent to the standard output before the pipe, and placing it in to the current directory (/mnt, or the / partition of the new drive). And that's it.

I then did the same thing with my /boot partition (with the exception of the -X switch; there isn't anything in there I want to skip over).

I powered down, removed the drive, put it back in my other computer, and booted up. I had copied the hard drive and was up in running in a matter of minutes, and now had two different machines running identical software set ups.

subcultured
Premium Member
join:2001-08-21
Jamaica Plain, MA

subcultured

Premium Member

^great explanation -- thanks :]

quick question, though: by piping the standard output of tar in such a way, is it creating unnecessary overhead? i think i remember reading that such a command doesn't actually archive anything, but can't remember... would a find command piped to "cp" be another viable option? a better option?

guycad$
In Search Of Free Speech
Premium Member
join:2002-05-02
Pompton Lakes, NJ

guycad$ to benyto

Premium Member

to benyto
oOOOOooooo! This is kewl! I've never seen it done this way before. This thread is definitely a keeper!

Thanks Benyto!!!

benyto
Premium Member
join:2000-07-09
Chico, CA

benyto to subcultured

Premium Member

to subcultured
quote:
quick question, though: by piping the standard output of tar in such a way, is it creating unnecessary overhead? i think i remember reading that such a command doesn't actually archive anything
That's pretty much the point. It allows you to make exact copies without having to first store the data in a file archive on your hard drive first. As far as overhead, ehh, I'm not sure that's a problem. It literally took just a few minutes to copy my root partition, and because the computer had to have been brought down in order to put the other drive in it, it can be assumed nothing mission critical was going on.
quote:

would a find command piped to "cp" be another viable option? a better option?
Quite possibly. I'd be interested to know if there are better ways to do this. However, I don't know them.
benyto

benyto to guycad$

Premium Member

to guycad$
Glad you found it helpful, guycad. I agree that this is a good thread. Some of the more mundane things like this really aren't discussed an awful lot.

guycad$
In Search Of Free Speech
Premium Member
join:2002-05-02
Pompton Lakes, NJ

guycad$

Premium Member

Some of the more mundane things like this really aren't discussed an awful lot.

Nope, you're right. Most people just set up one way to do their backups and then never think about it.