public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Recover file after truncate
@ 2017-07-26  0:48 Andy Bennett
  2017-07-26 11:15 ` Brian Foster
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Bennett @ 2017-07-26  0:48 UTC (permalink / raw)
  To: linux-xfs

Hi,

I have a file (~6GiB) that I was doing some analysis on. In the course of 
this I managed to do 'xxd something-else my-file' and overwrote it with < 
4.0K of data.


Running xfs_bmap on it gives me:

-----
my-file:
        0: [0..7]: 236935320..236935327
-----

Running xfs_bmap on another, similar big, file that was created around the 
same time gives me:

-----
other-file:
        0: [0..4194175]: 335806496..340000671
        1: [4194176..13828055]: 342870632..352504511
-----


A quick experiment with xxd suggests that the inode of the file remains the 
same if it exists before xxd writes to it. So my new file still has the 
same inode as the one I want to recover.

There hasn't been any write activity on this file system since I made this 
mistake.


Is there any hope of recovering any part of the original data?

I have an xxd dump of the first 624 bytes of the original file and there 
are some recurring features in it.

Grepping through the partition for that signature gives me this:

-----
$ sudo grep -obUaP "\x66\x66\xa2" /dev/nvme0n1p8 |tee TRACE
grep: exceeded PCRE's line length limit
519554640:ff¢
4377654787:ff¢
7961215381:ff¢
10165641473:ff¢
10849981825:ff¢
17851384491:ff¢
23231901998:ff¢
33898050969:ff¢
41781142596:ff¢
51651699392:ff¢
56040569029:ff¢
56277711167:ff¢
56814897544:ff¢
61037797435:ff¢
61269592210:ff¢
73946170693:ff¢
75199462354:ff¢
76071192135:ff¢
-----


The partition is on an NVMe SSD.


I'm not sure how to use xfs_logprint but converting the inode number to hex 
and grepping through doesn't seem to give me any matches.



Is there a way to find out how this file was allocated and restore it or 
fish the data out some how?

My mount options are

-----
/dev/nvme0n1p8 on /var/spool type xfs (rw,relatime,attr2,inode64,noquota)
-----

...and I'm running under Debian Jessie.

I've not (knowingly) got any manual TRIM or DISCARD jobs that will run.



What's the best way of working out what current files the offsets from grep 
correspond to? I guess the ones that don't correspond to a current file 
might be my data?



Thanks for anything you can do to help.




Regards,
@ndy

-- 
andyjpb@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-07-30 14:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-26  0:48 Recover file after truncate Andy Bennett
2017-07-26 11:15 ` Brian Foster
2017-07-26 22:12   ` Andy Bennett
2017-07-27 12:43     ` Brian Foster
2017-07-27 15:04       ` Brian Foster
2017-07-30 14:36         ` Andy Bennett
2017-07-30 14:41       ` Andy Bennett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox