[H-GEN] quick Q
Jason Henry Parker
jasonp at uq.net.au
Thu Feb 22 16:49:42 EST 2001
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Please observe the list's charter. ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]
Stephen Brine <sbrine at powerup.com.au> writes:
> Is there an easy way to replicate an installed linux installation
> Situ is i have a dying HDD and I want to copy it to a new hdd
> Rather than try and back the lot up then reinstall then unback.
> This is a relativly low critical machine, if I have to redo linux so be it
In all seriousness I suggest that this is a good time to learn about
backups. I'm going to assume you don't have backup media available,
but that you do have a network (since if you had backups, you wouldn't
be asking this, and a computer without a network is like, *shudder*),
If you have the new drive in the old machine, you could (naively) try
using cp:
# cp -ax / /new # archive, don't cross filesystems
but this will fail when you encounter things like devices, files with
holes, and so on. So then you may try:
# rsync -Wax / /new # archive mode (preserve almost everything) don't
# cross filesystems, copy whole files
This is a fairly good solution, but the time required for rsync to
work out what's going on before copying anything is prohibitive.
So it may be better to try things that are more typically used for
backups, right? How about tar?
# tar cf - / | ( cd /new; tar xf -)
This is truly horrible. It will take forever (espescially if you are
silly and use the `z' option to tar (ie, compress)) and can be tricky
to get right. Because Tar Sucks(TM) the example I've shown here won't
preserve permissions, links, recreate devices, so on and so forth.
The reason it's useful is it reduces the problem to making a stream
that is read by a program at the other end of the pipe that simply
undoes what the left hand side does. And because you have a pipe,
you can run it over the network!
# tar cf - / | (ssh -t root at victim "cd /new; tar xf -)
or
murder# tar cf - / | nc victim 9999
victim# nc -l -p 9999 | (cd /new; tar xf -)
However, Tar Sucks(tm). Use dump. Dump is a nifty little program.
It works on the raw *partition* instead of at the filesystem level.
That means it'll find your superblock (basically the start of your
filesystem); and start walking down the tree looking for inodes that
have changed since the last backup. A full dump (level 0), when
restored, will yield an inode-perfect copy of your filesystem. If you
have some evil software that requires a licensing file to be on the
exact same inode as it was when you installed it, dump will do it.
# dump 0 bf 2 - /dev/hda1 | (cd /new; restore -rf -)
# or so. Level 0 dump, piped to a subshell which runs
# restore on a brand-new filesystem.
These are some of your options. There are certainly more.
jason
--
``Just because one proposes a measure to prevent promotion
of a risk-filled and controversial sexual behavior
doesn't make them divisive or bigoted.''
-- Nicholas J. Yonker,
Concerned Citizens for Sound Education
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.
More information about the General
mailing list