Using testdisk: How to Extract the Whole Directory Tree and Filenames (Deleted and Good) Only in ext4 Partition

Abstract: Resolve the inability to list ext4 directory trees and filenames in testdisk by switching to extundelete or debugfs.

Created: 2026-08-18 by

You cannot extract a directory tree or list filenames using testdisk on ext4 partitions because the tool lacks a file listing feature for this filesystem. testdisk is designed to recover deleted files by copying their contents, not to browse metadata. To view the directory structure of good and deleted files, you must use specialized tools like extundelete or photorec, which offer different capabilities for ext4 data recovery.

Understanding Testdisk Limitations on Ext4

Many users assume that testdisk functions as a universal data recovery browser similar to Windows Explorer. This assumption leads to confusion when attempting to retrieve just the filenames or directory hierarchy from an ext4 partition. The core issue is architectural: testdisk focuses primarily on partition table repair and boot sector restoration. While it includes photorec for raw file carving, its main interface does not parse ext4 inode tables to display file names or structures. When you run testdisk on an ext4 drive, the software identifies the filesystem type but restricts operations to copying entire files if they are marked as deleted in the journal. It does not provide a "List" command that outputs a tree of existing or removed directories. Attempting to force this behavior results in errors or incomplete data extraction. Therefore, relying on testdisk for structural analysis of ext4 volumes is fundamentally flawed. You need tools specifically engineered to read ext4 metadata structures, such as superblocks, group descriptors, and inode tables.

Distinguishing Between File Content and Metadata

It is crucial to understand the difference between recovering file content and recovering file metadata. File content refers to the actual bytes stored within the file, such as text, images, or video data. Metadata includes the filename, directory path, permissions, and timestamps. testdisk can often recover the content of deleted files by scanning for known file signatures. However, it strips away the original filename and directory context during this process. For ext4 partitions, the directory tree is stored in specific inode structures. When a file is deleted, the directory entry is unlinked, but the inode may remain until overwritten. Tools that specialize in ext4 can parse these residual structures to reconstruct the path. testdisk ignores these paths because its primary goal is to restore access to the file system itself, not to audit its contents. Recognizing this distinction prevents wasted time trying to find non-existent features in the wrong software.

Alternative Tools for Listing Ext4 Directories

Since testdisk is unsuitable for listing files, you should switch to utilities designed for ext4 forensic analysis. The most effective option for Linux environments is extundelete. This tool explicitly reads the ext4 journal and inode tables to identify deleted files and their original paths. It allows you to list all deleted files along with their full directory trees before you choose to recover them. Another powerful option is debugfs, which is part of the standard e2fsprogs package. This interactive debugger lets you inspect the filesystem directly. You can navigate through the directory structure and examine inodes without modifying the disk. For more advanced cases where standard tools fail, consider using Possible Steps for Failed Hard Disk Data Recovery on Ubuntu, which covers broader strategies when standard filesystem tools encounter corruption. These alternatives provide the visibility into the directory tree that testdisk simply cannot offer.

Using Extundelete to Extract Directory Trees

To successfully list the directory tree and filenames, follow these steps using extundelete. First, ensure the affected partition is unmounted to prevent further writes. Running recovery tools on a mounted partition risks overwriting the very data you wish to see. Use the umount command followed by the device identifier, such as /dev/sdb1. Once unmounted, install extundelete if it is not already present on your system. Then, execute the list command. The syntax typically involves specifying the partition and the action. For example, running extundelete /dev/sdb1 --list-deleted will output a detailed list of deleted files. Each entry includes the inode number, the full path, and the deletion timestamp. This output effectively reconstructs the directory tree as it existed at the time of deletion. If you need to recover both good and deleted files, you can specify the target directory. The tool will copy the files while preserving their original names and paths. This method ensures that you retain the hierarchical structure, which is lost when using raw carving tools. Always verify the integrity of the recovered files afterward to ensure no data corruption occurred during the extraction process.

Recovering Good Files and Deleted Items Together

Sometimes the goal is not just to see deleted files but to catalog everything, including files that are still accessible. In such cases, mounting the partition in read-only mode is the safest approach. Use the command mount -o ro /dev/sdb1 /mnt/recovery. This creates a temporary mount point where you can browse the directory tree normally using standard commands like ls or find. However, this only shows currently valid files. To include deleted items in the same view, you must combine the read-only mount with extundelete. Run extundelete in list mode to get the deleted entries, then merge this information with the live directory structure. This hybrid approach gives you a complete picture of the partition's state. For scenarios involving complex partition layouts, refer to Reassembling Disk Partitions from Separate Images in Linux to ensure your logical volume is correctly identified before attempting recovery.

Common Pitfalls and Best Practices

A frequent mistake is running testdisk repeatedly on the same partition, hoping for different results. This wastes time and increases the risk of accidental writes. Another pitfall is ignoring the journal. Ext4 journals contain transaction logs that help reconstruct recent changes. Specialized tools leverage this data, while generic scanners do not. Always prioritize tools that respect the ext4 journal structure. Additionally, be cautious with large partitions. Listing thousands of files can consume significant memory and processing power. Use filters to narrow down the search by date or file extension if possible. If the partition is severely damaged, consider creating a disk image first using ddrescue and performing all analysis on the image. This protects the original hardware from further stress.

Frequently Asked Questions

Can Photorec list filenames for ext4?

No, Photorec operates by scanning for file signatures rather than parsing filesystem metadata. It recovers files based on their content structure, assigning them generic names like file001.jpg and discarding the original directory paths. It cannot provide a directory tree or original filenames for any filesystem, including ext4.

Is Testdisk completely useless for ext4 data recovery?

Not entirely, but its utility is limited to specific tasks. Testdisk can help repair the partition table or boot sector if the partition has become inaccessible due to structural damage. However, it cannot browse, list, or recover individual files with their original names from within the ext4 filesystem itself.

What if my ext4 partition is encrypted with LUKS?

You must decrypt the partition before using any ext4-specific recovery tools. Use cryptsetup to open the LUKS container and map it to a device mapper node. Once decrypted, treat the underlying block device as a standard ext4 partition for recovery purposes. See Restoring LUKS2 encrypted partition on Windows created MSR overwrote partition table for related decryption challenges.

How do I recover files if extundelete fails?

If extundelete cannot locate the files, the inodes may have been overwritten. In this case, you might try foremost or scalpel for raw carving, though you will lose filenames. Alternatively, consult guides on Unable to Recover BTRFS Partition: What to Do? for broader forensic techniques applicable to various modern filesystems.

Should I format the drive after using testdisk?

Never format the drive immediately after a failed recovery attempt. Formatting creates new directory structures and metadata that can overwrite remaining deleted data. Instead, keep the partition intact and continue testing different recovery tools. Only format the drive once you have successfully extracted all desired data or decided the drive is irreparable.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More