Recover Deleted Files in Linux
How to Recover Deleted Files in Linux
This documentation is not yet complete
Using TestDisk
TestDisk: Best for recovering lost partitions or undeleting files from specific filesystems like ext2, FAT, or NTFS while keeping original filenames

- TestDisk Official Documentation - https://www.cgsecurity.org/wiki/TestDisk
Using PhotoRec
PhotoRec: Ignores the filesystem and "carves" data directly from the drive. It is highly effective for photos, videos, and documents but will often recover files with generic names (e.g., f12345.jpg)

- PhotoRec Official Documentarion - https://www.cgsecurity.org/wiki/PhotoRec
Basic Steps for PhotoRec
Install: sudo apt install testdisk
Run: sudo photorec
- PhotoRec Official Documentation - https://www.cgsecurity.org/testdisk_doc/photorec.html
- Step by Step (with images) - https://www.cgsecurity.org/wiki/PhotoRec_Step_By_Step
- Disk selection
- Source partition selection
- PhotoRec options
- Selection of files to recover
- File system type
- Carve the partition or unallocated space only
- Select where recovered files should be written Do not store the recovered files on the source filesystem. Otherwise lost data may be overwritten and definitively lost
- Recovery in progress
- Recovery is completed
- PhotoRec: file name and date
- PhotoRec: matching filename and data location
How would I do it?
I would shut down the server.
I would add a new disk.
I would boot from a Live CD (I prefer Linux Mint).
I would install TestDisk in live mode.
I would run PhotoRec, choosing the original disk as the source and the newly added disk as the destination.
Targeted Filesystem Tools
Specific tools exist for common Linux filesystems:
extundelete: Specifically designed for ext3 and ext4 filesystems.
Command: sudo extundelete /dev/sdX1 --restore-all.
Summary of Popular Tools
| Tool | Best For | UI Type |
|---|---|---|
| TestDisk | Recovering partitions and FAT/NTFS/ext2 undelete | Command-line (Interactive) |
| PhotoRec | Hard-to-find files (images, docs) on any filesystem | Command-line (Interactive) |
| extundelete | Quick recovery on ext3/ext4 partitions | Command-line |
| R-Linux | Free GUI tool specifically for ext2/ext3/ext4 | Graphical (GUI) |
References
- Top 10 Tools - https://www.digitalocean.com/community/tutorials/top-best-linux-data-recovery-tools
- Tutorial - https://www.digitalocean.com/community/tutorials/photorec-recover-deleted-files-in-linux-ubuntu
- Official Documentation - https://www.cgsecurity.org/wiki/PhotoRec_Step_By_Step
Videos
- Recover Deleted Files Linux - https://youtu.be/xYmilDp682A?si=DAx5PsmaWjuy_fml
- Recuperar Partição do HD - https://www.youtube.com/watch?v=MJWJPFrxxTY