[Techtalk] dying hard drive

Akkana Peck akkana at shallowsky.com
Fri Dec 1 03:50:49 UTC 2006


Maria McKinley writes:
> Asking for more advice... I have a disk that is definitely on its way 
> out. When I boot, it has numerous unrecoverable errors (in the /usr 
> partition), but it does boot up and run. What is the best/easiest way 
> for me to transfer stuff to a new drive?

I've seen suggestions involving dd and similar raw disk copies, but
if the old disk is still working, I've had the best luck with file
by file copies. You'll miss out on data from any file that's
actually corrupted on the disk, of course, so if your disk is
bad enough that that's happening, AND you're ambitious enough
that you actually plan to try to recover data from corrupt files,
then use one of the other methods like dd.

For file level copies, there are a couple of methods that work well.
First, rsync is easy and convenient. If you're copying over the
network to a disk mounted on another machine:
  rsync -axv olddir/ otherhost:newdir/
(The x tells it not to cross filesystem boundaries, so e.g.
if you're trying to copy the / filesystem, it won't recurse
into other filesystems like /boot or /home or /proc or whatever.)
You might want to add a -e ssh if you don't run rsyncd and don't
already have RSYNC_RSH set in your environment.

If you can mount the new disk at the same time as the new disk,
then just use this:
  rsync -avx olddir/ /path/to/newdir/

Or you can use tar. You can make a backup tar file which you
can then extract wherever you want:
  cd olddir; tar czlf /somewhere/safe/disk-backup.tar.gz
(The l is the "one file system" option, like x in rsync.)
Or you can create and extract the archive all in one line,
to copy a directory hierachy somewhere else:
  cd olddir; tar czlf - ./ | (cd newdir; tar xzvf -)
This used to be the normal way to copy directories somewhere else,
but honestly now that rsync is available everywhere I'm not sure
if there's any advantage to using tar.

-- 
    ...Akkana
    "Beginning GIMP: From Novice to Professional": http://gimpbook.com


More information about the Techtalk mailing list