November 28, 2004

Recovering corrupted flash cards

Last night I had an unfortunate incident with Snow...whilst attempting to extract photos from a compact flash card, Windows ended up corrupting the card, probably by deleting the partition table. There's always that feeling of dread when you lose a whole bunch of valuable photos from a flash card, and it seems that thre's nothing that can be done as nothing is able to read the card again...right? WRONG!

With a bit of geek work, I discovered that it is in fact possible to recover the images from a flash card, as usually it's only the FAT and partition tables that get trashed, rather than the data itself. I wrote a little tool in perl to take advantage of this, and was able to successfully recover all but one photo.

The tool is deceptively simple. Just take a dump of the entire flash card with 'dd', and feed it to this tool, which looks for special bytes in the data that signify a JPEG image, and it extracts it to separate files.

Download script

The script doesnt guarantee complete recovery and may in fact recover very few images. The ideal situation for recovery is this:

  • Flash was formatted or completely deleted
  • Photos were taken WITHOUT anything being deleted
  • Disaster struck

In that case, recovery is likely to be full. If you delete photos with your camera (eg to re-take a shot) then fragmentation is likely and recovery of some photos will be hard. Note that ONLY jpeg image files will be recovered, but it's easy to change the script for other file types, just by editing the magic number.

I'd be interested in hearing any success stories with this tool.

Posted by Ben at 02:18 PM | Comments (1)

November 09, 2004

Pound web proxy

On my home network, I've got several machines running, with various functions. I've got my gateway/mail/web server, desktops, a Dreambox satellite receiver, and a linux PVR box running MythTV and VDR. Some of my internal machines are running web servers of their own - in particular the VDR box and my dreambox sat receiver have web servers through which program schedules can be made with a web browser from anywhere.

However, having a static single IP address means that these machines aren't reachable from the outside through my NAT gateway, unless I put in some port forwarding. I did this for a while, forwarding unused TCP ports to the web servers on the inside, but it's rather messy.

I found a solution at last, and it uses Pound, a very simple application which proxies incoming HTTP requests, much like any other reverse proxy solution, and forwards them onto different machines depending on attributes in the Host header. With this, I can now make different virtual hosts, and they all get redirected to the right machine and right port number, all from one tcp port on a single IP address.

With this single binary and a very small (10 line) config file, I now have going to one box, to another box, etc. A default directive catches all other Host headers to my main server.

Posted by Ben at 12:58 PM | Comments (1)

November 01, 2004

Plucking nylon - twang!

I've entered the world of music. On Friday evening, I went with a colleague who helped me select a new guitar for me to learn. Over the last while or so I've had a desire to learn guitar, and finally got the encouragement I need after visiting Pete in London and strumming on his guitar.

My new baby is a Spanish made Esteve GR01, and was the best sounding one I heard in the price range I had in mind.

Now it's Monday and the tips of my left hand fingers are rather sore, but I'm very satisfied so far and have had a great weekend getting the hang of chords, etc. I can even belt out a couple of bars of the Chili Peppers.

Posted by Ben at 11:27 AM | Comments (0)