3

Ok, so my Ubuntu 12.10 install seems to have gone slightly sideways. It currently boots from a Compactflash card that I was planning on replacing soon, but as luck would have it it's gone down now. The boot process gets to a certain point and then just sits there, and if I boot up a distro off a flash drive and then mount up the LVM partition, the live distro freezes after a couple of minutes. Now I'm not averse to installing and starting again, but I would love to pull off all my config files etc (all user data is stored on a separate ZFS pool).

Is it worth me trying to fsck the drive first, or am I better off avoiding doing anything more to it?

If so, how about importing the ZFS pool and then DDing the filesystem to an image on the pool? That way I'll be able to gain access to it.

RichVel
  • 3,524
  • 1
  • 17
  • 23
alanbeard
  • 141
  • 9

1 Answers1

2

I'd NOT fsck the drive as is - this risks damaging data further. I've actually done this recovery process in other situations, and I think it should work here.

Firstly, you want a copy of the drive, well, as far as possible. While DD is the tool everyone thinks of using, gnu ddrescue (aka ddrescue in the repositories - NOT dd_rescue, which is an unrelated bit of software) is probably what you want to do - this copies the contents of the drive, skipping anything thats messed up. I'd suggest imaging the root device (/dev/sdx) rather than a partition. As a bonus, ddrescue has a much simpler syntax than vanilla dd.

Then loopmount the images in your system - a standard loopmount will do with a single partition, but I favour kpartx for this - kpartx -a imagename.img mounts all the partitions inside imagename.img. You can then treat the image as any partition and run your preferred recovery software.

Journeyman Geek
  • 6,969
  • 3
  • 31
  • 49
  • More specifically, `dd` halts when it encounters a read error. `ddrescue` attempts to continue on to the next block. – Scott Pack Jun 17 '13 at 14:56
  • If `ddrescue` isn't available, `dd conf=noerror,sync` is usually close enough. Granted `ddrescue` provides a lot more and useful information, but in a squeeze `dd` gets the recoverable data off the medium. – Chris S Jun 17 '13 at 14:59
  • @ScottPack `dd` has a `noerror` option. See `man dd` – Chris S Jun 17 '13 at 14:59
  • 1
    Yup, and retries, AND lets you know how much data is actually corrupted. http://superuser.com/questions/355310/dd-rescue-vs-dcfldd-vs-dd/355322#355322 - covers the difference beween 3 major DD varients (and more importantly, different uses of DD varients) – Journeyman Geek Jun 17 '13 at 14:59
  • 1
    @ChrisS: thats not all it does tho. http://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html - it also does file copying in a manner that lets it maximise recovery – Journeyman Geek Jun 17 '13 at 15:02
  • Thanks for the input guys, I'll give ddrescue a go and see how I get on. I'll also make a backup of the backup so I've got one copy that is untouched. – alanbeard Jun 17 '13 at 16:01
  • @ChrisS: Read the man page? That sounds lame. – Scott Pack Jun 17 '13 at 17:10