LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-27-2008, 02:50 PM   #1
0x29a
LQ Newbie
 
Registered: Jun 2004
Posts: 16

Rep: Reputation: 0
Help recovering damaged tar.gz file


Before endeavoring to help I must tell you that I am not a programmer by any stretch. I'm using linux, kernel version 2.6.18.8. I'm working from the link below to arrive where I'm at so far:
http://linux.derkeiler.com/Newsgroup...4-03/0561.html

First of all, I am working with a gzipped tar file. I suspect that fixing the gz file will still leave me with a corrupt tar file. Please do not hesitate to let me know if reconstructing/recovering the tar file is futile. I am also using khexedit, which I suspect I will need to fix the .gz and tar file within it.

I've downloaded gzip version 1.3.12, edited unzip.c to include
Code:
fprintf(stderr, "bytes_in %ld\n", bytes_in);
The package compiled perfectly.

I ran:
Code:
tar zxvf damaged.tar.gz
(It's a big file, 3.2GB)

This gave me
Code:
<files extracted up to damaged part of file>
bytes_in 469237760

gzip: stdin: invalid compressed data--format violated
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
The questions I have are figuring out disk block size and how to concatenate a valid .gz header.

This is the layout of the hard drive where the tar.gz file was backed-up to:
Units = cylinders of 16065 * 512 = 8225280 bytes

The drive layout is probably not terribly relevent with the exception of figuring out where I am in the file on disc.

I've also read algorithm.doc that is included with the sources but it's beyond my ability to grasp. Also, would anyone be able to paste a commented header example that I can look at?

Please do not hesitate to let me know if there is more information I can provide.

Thanks,
Andrew
 
Old 10-27-2008, 04:07 PM   #2
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.15.5
Posts: 1,497
Blog Entries: 12

Rep: Reputation: 154Reputation: 154
Well, I'm not a progammer by any stretch of the imagination either, but this is how I would approach this problem:

Make a new file called example.txt -doesn't matter what's in it. Just fire up khexedit and type something and save it. Then gzip it to create example.gz. Then open up example.gz and look for the text title example.txt. Copy the block up to the text "example.txt" and save it as header.gz. I've almost certainly missed something entirely because of the bit shifting the howto talks about. You might have to try a few times to get a valid header.

To concatenate this to your damaged piece of damaged.gz use

cat header.gz damagedpiece.gz > newfile.gz

To get the damagedpiece.gz file you'll have to take the damaged.gz file and remove the first 469237760 bytes from it using khexedit; that will leave however much of it you haven't extracted yet. I presume the rounding to the nearest compression blocks means that you'll have to round to the nearest 8*64K bits.

Hopefully, half competent help is no worse than no help at all.
 
Old 10-27-2008, 05:12 PM   #3
0x29a
LQ Newbie
 
Registered: Jun 2004
Posts: 16

Original Poster
Rep: Reputation: 0
Thanks mostlyharmless. Indeed, I've built a career on half-competent help. So, thank you for helping me think this through. Creating a mostly empty tar.gz file is a really good idea. Hadn't gotten enough clarity to think about that in my frothing, "omg, my home directory is toast" quest for answers. :-)

As a future note to myself: Never backup to a nfs share again, and in the future add the -W switch to verify the archive...

Oh boy. I'll give your suggestion a whirl and post the result.

Thanks again,

Andrew
 
Old 10-28-2008, 02:30 AM   #4
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Suggest reading this:
http://www.gzip.org/recover.txt
 
Old 10-28-2008, 02:29 PM   #5
0x29a
LQ Newbie
 
Registered: Jun 2004
Posts: 16

Original Poster
Rep: Reputation: 0
Hi ya H_TeXMeX_H,

Thanks for the file. That's the same information that's referenced at the link in my original post. I've gotten to the part of the gzip source compile and retrieving the information before the defect in the file. The part that's still got me is concatenating a new header on the the damaged file beyond the defective part. One of the obstacles I'm running in to is the shear size of the file. khexedit just chokes because it wants to load the entire file in the memory before working on it, and it's been a really long time since I used to edit files directly on disc back in DOS 3.3 and 5.0 (anyone remember x-tree?). So for now, I grabbed a backup from a month or so ago and am trudging on. I haven't given up, I'm just temporarily stuck.

I'll post more when I have more info.

Thanks,

Andrew
 
Old 10-28-2008, 03:12 PM   #6
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Quote:
Originally Posted by 0x29a View Post
Hi ya H_TeXMeX_H,

Thanks for the file. That's the same information that's referenced at the link in my original post.
Oh, hehe, sorry I didn't notice, it looked different to me.

Try using regular hexedit, I've never noticed any slowdown when opening large files with it, it opens them instantly.
 
Old 10-28-2008, 03:28 PM   #7
0x29a
LQ Newbie
 
Registered: Jun 2004
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by H_TeXMeX_H View Post
Oh, hehe, sorry I didn't notice, it looked different to me.
Hehehe, no worries. :-)

Quote:
Originally Posted by H_TeXMeX_H View Post
Try using regular hexedit, I've never noticed any slowdown when opening large files with it, it opens them instantly.
Awesome. Installing now. Thank you for the tip! I'll let you know how it goes.

Andrew
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strategies for recovering JPEG files from a damaged filesystem yello Linux - General 2 12-17-2007 03:22 PM
Help recovering damaged partition matheusleite Linux - Newbie 1 10-10-2007 12:48 PM
Recovering damaged flash drive Avatar33 Linux - Hardware 5 03-12-2005 07:50 AM
Recovering data from damaged CD corn Linux - Hardware 4 09-23-2004 12:32 AM


All times are GMT -5. The time now is 09:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration