How to retrieve deleted files from a formatted SD card on Linux

Mastering SD Card Data Recovery on Linux: Your Comprehensive Guide

Experiencing data loss on your SD card can be a nightmare, especially when using a Linux machine. In this guide, we will navigate through the intricacies of SD card data recovery on Linux, providing step-by-step solutions to ensure you reclaim your lost files.

Reasons for Data Loss

Accidental File Deletion and Formatting

One common cause of data loss is accidental file deletion or formatting. Fear not, as these files are not lost forever. Our detailed recovery methods ensure that even in the case of these mishaps, your data is easily retrievable.

SD Card Corruption

Corruption, often triggered by viruses or improper ejection, can render your SD card inaccessible. Our comprehensive recovery guide addresses both file system errors and physical damage, offering solutions tailored to your specific situation.

Step-by-Step Recovery Process

Step 1: Mount Your SD Card

Mounting your SD card is the first crucial step. Our detailed instructions, accompanied by visual aids, ensure that even if your Linux distribution faces auto-mounting issues, you can swiftly proceed to access and modify your SD card’s contents.

graph TD

A[Open Linux Terminal]
B[Type lsblk and hit Enter]
C[Type sudo mount /dev/(your card’s device ID) /(mount location) and hit Enter]
D[Check Files window for confirmation]
A -->|1| B
B -->|2| C
C -->|3| D

Step 2: Back up Your Data

Creating a backup is crucial before proceeding with recovery. We recommend using gddrescue to ensure a bit-by-bit copy of your SD card, preventing further wear and possible damage.

graph TD

A[Open Linux Terminal]
B[Type sudo apt install gddrescue and hit Enter]
C[Type sudo ddrescue -d /dev/(your SD card’s NAME) /(path of image file)/(image filename).img and hit Enter]
D[Wait for backup process to complete]
A -->|1| B
B -->|2| C
C -->|3| D

Step 3: Recover Files from the SD Card

With your data backed up, choose the appropriate method based on your data loss scenario. Method 1, using TestDisk, is ideal for corrupted SD cards, while Method 2, utilizing PhotoRec, is suitable for accidental deletions or formatting.

graph TD

A[Open Linux Terminal]
B[Type sudo apt install testdisk and hit Enter]
C[Type testdisk and follow on-screen instructions for corrupted SD cards]
D[Type sudo photorec and follow on-screen instructions for deleted or formatted data]
A -->|1| B
B -->|2| C
C -->|3| D

 

Fixing a Corrupted SD Card

Once your data is restored, the next step is repairing the SD card to prevent future issues.

Method 1: Repair the SD Card Partition Using GNOME Disk Utility

GNOME Disk Utility’s Check Filesystem feature automatically detects and fixes errors on your SD card’s file system.

graph TD

A[Open Disks app in Linux Terminal]
B[Select SD card from left sidebar]
C[Click gear icon and select Check Filesystem...]
D[Click OK to confirm]
A -->|1| B
B -->|2| C
C -->|3| D

Method 2: Format the SD Card

Formatting your SD card creates a new file system, marking bad sectors and minimizing the risk of future data loss.

graph TD

A[Open Disks app in Linux Terminal]
B[Select SD card from left sidebar]
C[Click gear icon and select Format Partition...]
D[Name SD card, select For use with all systems and devices (FAT), and click Format]
A -->|1| B
B -->|2| C
C -->|3| D

 

Frequently Asked Questions

  • How to recover data from an SD card in Ubuntu?

    • Follow our comprehensive guide for step-by-step instructions.
  • How to recover deleted photos from an SD card on Linux?

    • Utilize Method 2 with PhotoRec for effective recovery.
  • Why is Linux not detecting my SD card?

    • Refer to our troubleshooting section for potential solutions.

Conclusion

With tools like TestDisk and PhotoRec, recovering data from your SD card on Linux is not only possible but made easier. Follow our detailed guide to safeguard your data and efficiently tackle data loss scenarios on your SD card. Remember, preparation is key, and our step-by-step solutions ensure a seamless recovery process on your Linux machine.