Testdisk won’t list files for an ext4 partition inside a LVM inside a LUKS partition

Mario asked:

I have accidentally deleted a file that I want to recover. The partition is an ext4 partition inside an LVM partition that is encrypted with dm-crypt/LUKS.

The encrypted LUKS partition is: /dev/sda2
which contains a physical volume, with a single volume group, mapped to: /dev/mapper/system
And the logical volume, the ext4 partition is mapped to:

A # testdisk /dev/mapper/system-home will notice it as an ext4 partition but tells me that the partition seems damaged when I try to list the files. If I # testdisk /dev/mapper/system it will detect all the partitions, but the same happens if I try to list their files.

Am I doing something wrong or is it a known bug? I have searched but haven’t found any clue.

My answer:

You’re doing something wrong.

testdisk is meant to operate on and recover disk partitions, which is not the problem you’re having. Most likely you want to use its companion tool photorec instead, which recovers deleted files (and not just photos).

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.