📅 2010-Apr-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ photorec, testdisk, ubuntu ⬩ 📚 Archive
Today a friend deleted a few photos from my camera SD card by mistake. But, recovering those deleted photos turned out to be quite easy. Here is how to recover deleted photos from a memory card on Ubuntu:
As soon as you discover the deletion, shutdown the device, take out the memory card and make sure it is made read-only. Most SD cards have a tiny latch, that when pulled down locks the card into read-only mode. For example, the yellow colored latch on my Kingston SD card in the photo above.
Put the card into the memory card reader slot on your computer. Typically, Ubuntu will mount it automatically.
Figure out the device name of the mounted memory card. This can be done by looking at the contents of
/etc/mtab. This text file holds the table of mounted devices on the computer. For example, my SD card is named
ASH_D40 and I found that its device name is
/dev/mmcblk0p1 by finding this line in
/dev/mmcblk0p1 /media/ASH_ND40 vfat rw,nosuid,nodev,uhelper=devkit,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,flush 0 0
Install the testdisk package. This is available on the Ubuntu repositories, so can be installed using Synaptic Package Manager. This package has photorec, a tool that can be used to recover photos from memory cards.
Execute photorec as superuser providing it the memory card device name:
sudo photorec /dev/mmcblk0p1$
1. **Partition table type**: For SD cards used in cameras, the choice should typically be `[Intel] Intel/PC partition` 2. **Partition**: Since most SD cards are formatted such that the entire space is a single partition, the choice could be `No partition [Whole disk]` 3. **Filesystem type**: Most SD cards are formatted as FAT16, hence the choice could be `[Other] FAT/NTFS/HFS+/ReiserFS/...`
Xis an integer.