Cloning a running Linux OS

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed Sep 10 14:56:18 UTC 2008


On Wed, Sep 10, 2008 at 10:35:20AM -0400, Tyler Aviss wrote:
> Just out of curiosity, while do you need to clone it while it is running?
> In most cases, I've managed to clone a non-running OS by plugging in a
> secondary drive (via USB or as a slave) and then mounting and
> tar-copying the files
> 
> cd /path/to/drive/mount
> tar -cf - * | tar -xvf - -C /path/to/new/mount
> 
> (or if you want it in a file, just tar to it).
> 
> 
> Tar's a little nicer about copying any special file attributes etc
> than a normal "cp"

cp -ax does a perfectly good job.  rsync -ax does as well.  With rsync
3, using -Aax even does ACL stuff, which tar doesn't.  Not sure if cp
does.  So tar is certainly NOT the tool for this job if you want to
preserve all attributes.  The -x makes it stick to one filesystem, so
repeate for each mounted partition seperately, which takes care of /sys,
/proc, /dev, etc without issues.

> Depending on what's running, you might be able to get away with
> tar'ing most of the drive live. Just skip the files in /dev and a few
> other places because I believe some of those
> behave a bit oddly (like copying memory-related /dev entries).

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list