Lost Your Files? Recover Them with PhotoRec
Accidentally deleted important files from your hard drive, USB, or SD card? PhotoRec can help bring them back from the digital grave. In this post, we’ll explore how to use this powerful open-source utility to recover your lost files safely and effectively.
What is PhotoRec?
PhotoRec is a companion tool to TestDisk, focused on data recovery. Unlike conventional recovery tools that rely on file system metadata, PhotoRec scans the raw disk space for known file signatures, making it extremely effective even when the filesystem is corrupted or missing.
Key Features
- File Recovery: Supports recovery of over 480 file extensions including photos, videos, documents, and archives.
- Cross-Platform: Available for Linux, Windows, and macOS.
- Works on Damaged Partitions: Recovers data even from corrupted or formatted partitions.
- No Installation Required: Portable and runs directly from the command line.
Installation
On most Linux distributions, install via your package manager:
sudo apt install testdisk # Debian/Ubuntu
sudo pacman -S testdisk # Arch-based
brew install testdisk # macOS with Homebrew
Usage: Step-by-Step Guide
1. Launch PhotoRec
Start the tool from the terminal with superuser privileges:
sudo photorec
2. Select Disk
Choose the disk that contained the deleted files. Make sure you're selecting the correct one to avoid further data loss.
3. Choose Partition and Filesystem Type
Select the partition and specify the filesystem type. If unsure, choose [Other] unless it's an ext2/ext3/ext4 Linux partition.
4. Select Options (Optional)
You can adjust settings like enabling brute-force recovery or excluding known files. The default options work well for most use-cases.
5. Choose File Types
You can narrow down recovery to specific file formats (like `.jpg`, `.pdf`, `.zip`), saving time and disk space.
6. Select Destination
Important: Do NOT save recovered files on the same drive you’re recovering from. Choose another drive or external disk to avoid overwriting deleted data.
7. Let It Run
PhotoRec will begin scanning and recovering files. Depending on disk size and speed, this may take minutes to hours.
Example Recovery Session
# Launch the program
sudo photorec
# Choose disk: /dev/sdb
# Select partition: [Whole disk]
# Filesystem: Other
# Choose file types: only .jpg and .pdf
# Save to: /home/user/recovered/
Tips & Caveats
- Avoid Writing: Once you realize files are deleted, avoid writing anything to the disk.
- Use External Destination: Always save recovered files to a different drive or USB stick.
- Be Patient: Raw scan methods take time and may recover fragmented or partial files.
When to Use PhotoRec
Use PhotoRec if:
- You’ve deleted files by mistake and they’re not in the trash/recycle bin.
- The partition is formatted or unreadable.
- Other file recovery methods failed due to filesystem corruption.
Conclusion
PhotoRec is a must-have in your data recovery toolkit. It's fast, reliable, and often works where other tools fail. Whether you lost vacation photos, project files, or important documents, give PhotoRec a try before giving up.
For more detailed information, visit the official guide.