Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Recover truncated file on ext3
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Emmeran
n00b
n00b


Joined: 28 Dec 2007
Posts: 32

PostPosted: Fri Feb 26, 2010 1:00 pm    Post subject: Recover truncated file on ext3 Reply with quote

Hi guys,

does anyone know how I can recover the contents of a file that has been truncated by gedit. I was editing a file on one of my web servers and somehow the connection was lost and gedit truncated the file. I didn't notice it and closed gedit. So now I have a file with 0 bytes...

Thx,
Emmeran
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 27780
Location: 56N 3W

PostPosted: Fri Feb 26, 2010 11:05 pm    Post subject: Reply with quote

Emmeran,

This is deliberately difficult. First, its important to make the partition read only as soon as possible to avoid the free space that contains your data from being reused. You need to search the free space with a hex editor for a known fragment of your file.

emerge hexedit

make the partition you want to read world readable with chmod /dev/sd... 664 This is a security hole, so reset 660 later but its better than running hexedit as root.

open the partition in hexedit hexedit /dev/sd... then search for someting you know was in the file. The longer the string the better, as the its less likely to occur in other files.

Look at every instance you find, mark the beginning and end of interesting finds, then save them to files.
Rinse and repeat until you can't find any more.

Looks that the files you have saved - pick the best one.

You will need to read man hexedit. Don't run it as root, there is no undo.
Don't forget to fix the permissions on your partition when you are done.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum