Recover deleted files with PhotoRec

photorec scans a device sector by sector, ignoring the filesystem, and carves out files it recognizes by signature — often recovering data after rm, a quick format or a corrupted card.

Linuxdiskdata-recoveryrepairMedium risk
Install testdisk (`sudo apt install testdisk`), unmount the card, run `sudo photorec` (or `sudo photorec /dev/sdb`), select the partition and a destination on another disk.

01Command

Command
$ sudo photorec /dev/sdb

02What it does

PhotoRec's signature-based carving works even when the filesystem metadata is gone, supporting hundreds of formats (JPEG, MP4, PDF, DOCX...). It is read-only toward the source device, so further damage is unlikely. For files deleted from a healthy ext4/ext3 filesystem, try `testdisk` first, which can undelete via the filesystem itself and preserve names and paths.

03Risk

RiskMedium risk
Requirementstestdisk package (provides photorec); unmount the target partition
!Warning: Stop writing to the affected device immediately — new data overwrites deleted files. Recovered files lose their original names and folder structure, and success is never guaranteed.

04Undo

Undo
$ null

05Sources

  • PhotoRec — file recovery
    CGSecurity · community · 2026-09-17
    Evidence: PhotoRec step-by-step recovery of files from disks and cards
  • PhotoRec Step By Step
    CGSecurity · community · 2026-09-17
    Evidence: advises writing recovered files to another disk

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions