LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2011, 04:30 PM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
.tar.gz file and possibly corrupted


I have a couple almost 30GB .tar.gz files on a RHEL box. I made copies of them on my PC and tried to get the contents out with iZarc, but it gave me a CRC error.

Is there a way to check the original file on the server to see if the original is truly corrupt too? I dont even know how to extract the data in one foul swoop through a linux command line, or if there's like a test mode i can run against the file that will save me some time before I try to extract the whole thing.
 
Old 02-15-2011, 04:36 PM   #2
sploot
Member
 
Registered: Sep 2009
Location: Phoenix, AZ
Distribution: Gentoo, Debian, Ubuntu
Posts: 121

Rep: Reputation: 27
To get the contents out in linux CLI:
Code:
tar -xzvf /path/to/file
This will verify that the file is not corrupted
 
1 members found this post helpful.
Old 02-15-2011, 04:40 PM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
so will this only do the verify, without extracting the contents to the disk? I'm really not sure how big this would be extracted so not sure how much disk space i would need for it to work anyway.
 
Old 02-15-2011, 04:49 PM   #4
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
You can run

tar -t file.tar.gz to list the contents of the archive. You can also take a md5sum hash of the original and compare it to the new one to see if the hashes match. If they're different then you know the new one is corrupt.

To extract a slew of tar.gz files in a directory just do
tar -xvf *.tar.gz
 
1 members found this post helpful.
Old 02-15-2011, 04:54 PM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
I'll try the tar -t file.tar.gz, as that sounds like it will just give me a listing of all the files and tell me if they're able to be extracted or not, if i decide i want to do that.

or did i misunderstand what that command will do?
 
Old 02-16-2011, 12:18 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I reckon you'll need the z flag as well to tell it it's a gzipped file

tar -tzf file.tar.gz
 
2 members found this post helpful.
Old 02-16-2011, 07:56 AM   #7
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks Chris. Your command is giving me some output to the screen now. It listed a bunch of files, but then it gave me a

tar: Skipping to next header

and hasn't produced any more output to the screen for a while. I'll let it go till it kicks me back to a prompt, but i'm guessing this may mean my file is corrupted and I won't be able to get all the data out of it?
 
Old 02-16-2011, 08:09 AM   #8
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Here are the last few things it said before taking me back to the prompt

Quote:
tar: Skipping to next header

gzip: stdin: invalid compressed data--crc error

gzip: stdin: invalid compressed data--length error
tar: Child returned status 1
tar: Error exit delayed from previous errors
guessing the means the file is corrupted and I wont be able to get everything out of it?
 
Old 02-16-2011, 11:01 AM   #9
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
Possibly. Do you have access to the original tar.gz?

Run
Code:
md5sum file.tar.gz
On the original and on the one you're working on. See if they match. If they don't then we know it's corrupt.
 
Old 02-16-2011, 11:03 AM   #10
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Those results in my last post were from the original file on the server, not my local copy.
 
Old 02-20-2011, 04:17 PM   #11
lbukys
LQ Newbie
 
Registered: Mar 2008
Posts: 8

Rep: Reputation: 0
Please forbear while I suggest a few things that might or might not be obvious to you:
Perhaps the .tar.gz filename lies, perhaps it's just a .tar file. Or really a .tar.bz2 file.
If you're comfortable with looking at bits of binary files, I would suggest dumping the first 512 bytes with 'dd bs=512 count=1 < filename.tar.gz | od -t c' and verifying that it really is a gzip file. A gzip file, for example, typically contains the name of the uncompressed file in the first few bytes of the compressed file.

If the file is truly corrupted, recovering data is nearly impossible, since errors in decompression affect every subsequent byte of output -- the decompression basically goes off the rails. That said, for the particular case of FTP ASCII transfers of gzip files, I have had success in recovering some data (see http://bukys.com/services/recovery/), but it basically requires some custom coding, so it's a consulting project not a turnkey operation, so you're probably not interested unless this data is extremely critical to you.

I have also seen cases where a Mac decompressor complains after a file reaches a certain size (perhaps it was at 3GB or 4GB). But if that were the problem, just a "tar ztv" would have shown partial success before failing later. If decompression fails immediately, with no output at all, that suggests to me that the file is corrupted or misidentified from the near the beginning. One more stupid question: if you run the "file" command, e.g "file filename.tar.gz", what does it identify it as?
 
  


Reply



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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
Possibly corrupted partition table? CD1212 Linux - General 1 12-18-2009 03:37 PM
Possibly corrupted X-server. Treval Mandriva 1 01-31-2006 02:27 PM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:53 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration