The next problem came when I tried to use testdisk to copy my files to a network location to prepare to flatten and rebuild my LVM volume group. My /home logical volume was/is a 20GB ext4 filesystem full of regular files, symlinks, and hardlinks. I selected the root folder for my user and asked testdisk to copy it and everything appeared to be working properly. However when I checked on it a short time later I was suprised that it was still running, and that it had copied over 90GB of data so far. I suspect it was not following links correctly and making multiple copies of things.
And so I decided to use the information testdisk had discovered about the location of my filesystem but let the linux kernel and rsync handle copying my data to a safe location. Taking a few snips from the testdisk log file:
Disk /dev/sda - 256 GB / 238 GiB - CHS 31130 255 63
I was able to calculate the LBA of the start sector of my filesystem, and then manually use device mapper to create a block device pointing at it which I could mount normally.recover_EXT2: s_block_group_nr=0/154, s_mnt_count=59/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 5072896
recover_EXT2: part_size 40583168
Linux 23430 211 14 25957 3 30 40583168
ext4 blocksize=4096 Large file Sparse superblock, 20 GB / 19 GiB
After which rsync had no problems copying the 12GB of data that were stored there.echo "0 40583168 linear /dev/sda 376416256" | dmsetup create test
mount /dev/mapper/test /mnt/test
Which brings me to my feature request - would it be possible to also include LBA addresses of everything in the testdisk log - having to convert from CHS on a modern system seems unnecessary. An even better bonus would be to include 'dmsetup' commands with all of the parameters supplied to create temporary block devices at the locations of everything found. Perhaps even provide the 'dmsetup' commands to create a snapshot of that device so you can do things like safely run a fsck against the filesystem without modifying any of the blocks on disk.
Edit: It occurred to me later that having the LBA addresses of things would also make it trivially easy to take images of specific parts of the disk using dd or some other tool. To borrow from my example above, I could have taken an image of that filesystem with "dd if=/dev/sda of=/location-with-space/filesystem.img bs=512 skip=376416256 count=40583168".