Skip site navigation (1) Skip section navigation (2)

Re: [sf-perl] Trustworthy laptop repair?

From: Eric Walstad <eric(at)ericwalstad(dot)com>
To: sfpug(at)postgresql(dot)org
Cc: Quinn Weaver <quinn(at)fairpath(dot)com>
Subject: Re: [sf-perl] Trustworthy laptop repair?
Date: 2007-01-18 00:16:37
Message-ID: 45AEBC65.2080908@ericwalstad.com (view raw or flat)
Thread:
Lists: sfpug
Fred Moyer wrote:
> On Wed, 17 Jan 2007, Quinn Weaver wrote:
> 
>> On Wed, Jan 17, 2007 at 03:09:45PM -0800, Fred Moyer wrote:
>>> On Wed, 17 Jan 2007, Quinn Weaver wrote:
>> I suppose if I just dd from the hard drive to a file, and then dd back
>> to the
>> new hard drive, it'll work... yes?  Then I won't have to reinstall
>> Ubuntu,
>> all its updates, non-free stuff like Flash, my /etc backups, and so on...
>>
>> Will this approach work?  I plan to do some research on my own,
>> but do you know of any caveats?
> 
> Only thing I can think of is that there may be bad blocks on your drive
> as a result of the zappage, so the dd may not go as cleanly as
> expected.  But then again, rsync would behave strangely also if the
> drive has physical oddities.  Suggest also rsyncing the contents with
> checksumming enabled as plan b.


What I've done with my Thinkpads (model A31), when suffering the same
symptoms, was to backup the data like this:
 1. boot to a live cd (I use Knoppix)
 2a. use dd to mirror the entire drive (or a partition) to a usb
external drive
 2b. use dd to restore the image from 2a either to a new drive or the
existing drive.

I have had success in restoring the image from the external drive:

Below are scripts I run to create the image(s) and to restore from
it/them.  Use them at your own risk with the understanding that a
botched call to dd could hose all your data.  That said, I hope they are
helpful.

Good luck,

Eric.


##### Create the dd image using dd_rescue #####
## Using dd_rhelp and dd_rescue in Knoppix:
#
# dd_rhelp runs dd_rescue and efficiently handles bad blocks so that
# a dying disk has a better chance of surviving the data rescue operation.
#
# Get the latest dd_rescue as knoppix ships with an old version
cd
mkdir -p ~/.dist/bin
wget http://www.garloff.de/kurt/linux/ddrescue/dd_rescue-1.12.tar.gz
tar xvzf dd_rescue-1.12.tar.gz dd_rescue
mv dd_rescue ~/.dist/bin

# Get the latest dd_rhelp
wget http://www.kalysto.org/pkg/dd_rhelp-0.0.6.tar.gz
tar xvzf dd_rhelp-0.0.6.tar.gz
cd dd_rhelp-0.0.6
./configure && make
cp dd_rhelp ~/.dist/bin/

# Mount the external drive to which the image will be saved
# (assumes sda3)
cd
sudo mkdir /big
sudo mount /dev/sda3 /big

# Backup the master boot record (optional)
sudo dd if=/dev/hda of=/big/my_mbr.img bs=512 count=1

# Now run dd_rhelp to make an image of the partition (assumes hda2)
sudo dd_rhelp /dev/hda2 /big/my_hda2_dd_rhelp.img

# Finally, run fsck on the image to attempt to repair any filesystem
# errors that occured
sudo fsck -y /big/my_hda2_dd_rhelp.img

# unmount the drive
umount /big




# If not worried about fsck-ing the data...
# Assumes:
#  - host name is 'pasauran'
#  - hard drive is /dev/hda
#  - external, usb, drive is mounted at /mnt/sda2

# Make an image of the master boot record only:
dd if=/dev/hda of=/mnt/sda2/pasauran_mbr.img bs=512 count=1

# Make an image of the entire hard drive (assumes drive is hda)
dd if=/dev/hda of=/mnt/sda2/pasauran_hda.img conv=noerror

# Make a gzip-ed image (more time, less size)
dd if=/dev/hda | gzip > pasauran_hda.img.gz

# Watch the backup process in another terminal
watch -n 10 ls -al /mnt/sda2/pasauran_hda.img

# Restore the entire hard drive image
dd if=/mnt/sda2/pasauran_hda.img of=/dev/hda

# Restore just the master boot record
dd if=/mnt/sda2/pasauran_mbr.img of=/dev/hda bs=446 count=1

# Restore the gzip-ed image
gunzip -dc /mnt/sda2/pasauran_hda.img.gz | dd of=/dev/hda

# Backup the MBR of a remote machine:
ssh my_user(at)remote_host "dd if=/dev/hda bs=446 count=1" | dd
of=/mnt/sda2/remote_host_mbr.img

In response to

sfpug by date

Next:From: Eric WalstadDate: 2007-01-18 01:23:52
Subject: Post-mature optimization...
Previous:From: Fred MoyerDate: 2007-01-17 23:45:07
Subject: Re: [sf-perl] Trustworthy laptop repair?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group