Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Recovering photos from an XD card

>>>>> "James" == James Sadler <freshtonic@xxxxxxxxx> writes:

James> Hi all, I stupidly removed an XD card from my card reader under
James> Linux without unmounting it first.  When I put the card back in
James> the machine, most of the pictures were missing.  I'm guessing
James> the filesystem is corrupt.  In theory the photos themselves are
James> still there.  Does anyone know how I could restore these under
James> linux?  I am running Ubuntu Jaunty.

Hmmm.  Were you copying files *to* the card? If so they may never have
got there (they'll still have been in Linux's filesystem cache).

If you know the filenames fsck.vfat can recover the files.

As always, first make a complete image copy of the filesystem in case
of errors:
  dd if=/dev/sdc1 of=/var/tmp/image bs=1M
(/dev/sdc1 is the damaged partition, could be something else).

  Use strings to find file names:
  strings /var/tmp/image

  Choose the ones to undelete, then
  fsck.vfat -rv -u /name/of/file/to/recover.jpg /var/tmp/image

(I've never tried to undelete more than one file at a time, but check
the manpage).

Then mount it with
  mount -oloop /var/tmp/image /mnt
and copy the files off:
  cp /mnt/name/of/file/to/recover.jpg /tmp

If this all doesn't work, the XD card's image is still intact for
another go with  different method.

Peter C

Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au           ERTOS within National ICT Australia
A university is a non-profit organisation only in the sense that it
spends everything it gets  ... Luca Turin.