[Cialug] Moving Linux from one disk to another

Paul Gray gray at cs.uni.edu
Fri Sep 5 09:19:59 CDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>>>> Zachary Kotlarek <zach at kotlarek.com> 09/04/08 4:41 PM >>>
> 
> On Sep 4, 2008, at 4:14 PM, Paul Gray wrote:
> 
>> dd takes too long
> 
> That depends on your usage. dd can be significantly faster if you have  
> a mostly full disk, or a large number of small file, or both. But a  
> file-based copy like tar or rsync will be much faster if you have a  
> mostly empty disk.
> 
> In any case, if you're going to copy files (with tar, cp, rsync, etc.)  
> as opposed to blocked (with dd) and are booted off another disk be  
> sure to use numeric UID/GIDs or you're likely to end up with bad  
> ownership.
> 

Bad ownership?

I must call "B.S." on this  -- 'rsync -plarv' (which is what I
suggested) preserves all ownership and permission IDs, and doesn't give
a hoot about entries in the target's /etc/{passwd,shadow}.  Certainly a
very naive use of the tar command would produce the permissions fiasco
that you describe.  I assert that if you're going to be naive about
using a tool, the naive use of dd would have even worse consequences.

UID/GID's are just numeric fields of the file descriptors, and rsync,
just like cp, preserves every bit of these fields *when told to do so*.
 My advice was "rsync -plarv", which if you look at the options,
preserves all the things that you want it to preserve.

With rsync, you also defrag your entire disk...with dd, you preserve
your fragmentation.  There -- some more fuel for the fire.

Fanning the flames even more: With rsync, you can also backup across a
network to your large storage array.  Unless you're recompiled bash with
socket support or are using udpcast, that's a bit harder to do with dd.

Even duping a live system that's starting to throw SMART errors on a
drive to the point where it might not boot up another time is something
that rsync can do across the network if you're adventurous.  Close down
your databases (and anything else with open files that are unlocked) and
issue:
  rsync -plarv --exclude='/proc/*' --exclude='/sys/*' \
         --exclude='/tmp/*' --exclude='/dev/*' \
         --exclude='/var/cache/apt/archives/*' \
         / root at backuphost:/backups/system-backup/

Take the target image, lay it across a fresh drive in another system in
the manner that I posted and you can have a hot-swap system ready to go
before the original fails.  (N.B. This works for "non-failing" systeems
also, if you haven't backed up for a while.)

... Backing up of live systems is *NOT* recommended with dd.

I should also be very, very clear about one fundamental thing that the
above ranting might not truly convey:  I *HATE* rsync.  It's analogous
to sendmail in my book.

- --
Paul Gray
314 East Gym, Dept. of Computer Science        -o)
University of Northern Iowa                    /\\
Supercomputing 2008 Education Program Chair   _\_V
Message void if penguin violated ...  Don't mess with the penguin
No one says, "Hey, I can't read that ASCII attachment ya sent me."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjBQA4ACgkQOH45TZW7mh5DKACgrEg0pnwhICahEY6mQBzT8UKN
zmsAn37RcGfHvGgWyzNkOzIlYx3bPMEn
=jeZ1
-----END PGP SIGNATURE-----


More information about the Cialug mailing list