On Wed, 31 Mar 2021 23:44:28 +0200
Thierry Testeur <thierry.test...@gmail.com> wrote:

> Yep, compression enabled (original fstab before having tried restore
> options): compress=lzo

Okay, that explains why photorec couldn't recover a lot. If you want to
get your hands dirty, I guess you could write a program that does the
following:
For every 4k block/address on the filesystem, attempt to decompress it
using the btrfs lzo implementation (see fs/btrfs/lzo.c and
lib/lzo/lzo1x_decompress_safe.c in the kernel).
Do some sanity checks:

Like, check that the length of the compressed data is reasonable. The
decompressed size of an compressed extend can be a maximum of 128k, so
considering the case that data which doesn't compress well may take up
more space in compressed from, the maximum length of the compressed
data should be a bit larger than 128k. I'd say like 256k.

Also check that the length of the segments is reasonable, etc.

If all sanity checks passed and decompression worked, look at the
decompressed size:

If it is exactly 128k, it is likely part of a bigger file. Append all
such data to a output file.

If it is below 128k, chances are pretty good you just recovered a small
file, save it directly somewhere. You can use the file(1) utility later
to figure out the file-format.
Or it could be the last part of a large file, so always append it to
the output file as well and fill up with zeroes so the end is aligned
to 4k.

Finally, you can run photorec on the output file that you appended
everything to, to rescue files that are larger than 128k.

I wish you luck.

Regards,
Lukas Straub

> Best regards,
> Thierry
> 
> Le mer. 31 mars 2021 à 14:23, Lukas Straub <lukasstra...@web.de> a
> écrit :
> >
> > On Wed, 31 Mar 2021 02:17:48 +0200
> > Thierry Testeur <thierry.test...@gmail.com> wrote:
> >  
> > > Hello,
> > >
> > > if anyone can help me with the problem above?
> > > Have tried a Photorec (even if i know the chance are really
> > > poor), and have got some non-sens files, lkie pdf of 2Gb, ....
> > > most of them are unusable, except smal size file, like jpg pic...
> > >
> > > thanks for any help.
> > > Thierry  
> >
> > Weird, I would have expected photorec to recover more. Did you have
> > compression enabled?
> >
> > Regards,
> > Lukas Straub
> >
> > --
> >  



-- 

Attachment: pgpG0ipQdbcpM.pgp
Description: OpenPGP digital signature

Reply via email to