13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATAsudo dd if=/dev/hda of=/mnt/recovery/hdaimage.ddThis may take a while to run!By default, dd will abort on error. Avoid this with the noerror option:sudo dd conv=noerror if=/dev/hda of=/mnt/recovery/hdaimage.ddAnother option is the GNU utility ddrescue, with which you can skip the dodgyareas (dd will keep trying to get at bad areas of disk). This is the gddrescuepackage (and the utility is called gddrescue) in Debian/Ubuntu. Note that thisis not the same as the package/utility dd_rescue, which is a slightly less usefulprogram.gddrescue -n /dev/hda /mnt/recovery/hdaimage.raw rescued.logThis command will grab most of the error-free areas quickly, after which youcan rerun it with -r 1 instead of -n to get as much as possible of the badpatches. This is especially useful if you’re worried about how long your diskwill continue to spin, because you can get a copy of any good dataimmediately.Once you have your bit-for-bit copy, you can run fsck on it:fsck /mnt/recovery/hdaimage.ddNext, if it’s a single-partition drive, you can mount the image as a loopbackdevice:mount -o loop /mnt/recovery/hdaimage.dd /mnt/hdaimageIdeally, your data will now be available at /mnt/hdaimage. However, if yourfailed disk had multiple partitions, you’ll need to do a little more work. Findout where the partitions are with this:fdisk -lu /mnt/recovery/hdaimage.ddwhich will list the start and end cylinders of each partition and the units inwhich they’re measured. If the second partition starts at cylinder 80300 andthe units are 512 bytes, then that partition starts at 80300 × 512 = 41,113,600bytes. In this case, the command you want looks like this:mount -o loop,offset=41113600 /mnt/recover/hdaimage.raw /mnt/hdaimageFinally, you can use dd again to write the image back onto another disk, forexample, /dev/hdb:dd if=/mnt/recovery/hdaimage.raw of=/dev/hdb■ Note Another emergency rescue tip for a bad disk: put it in the freezer for a few hours (in a watertight sealedbag). This may sound odd, but cooling the disk can give it a brief lease of new life—long enough for you to grabyour data from it.115Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!