LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Rep: Reputation: 47
.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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Original Poster
Rep: Reputation: 47
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,033

Rep: Reputation: 69
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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Original Poster
Rep: Reputation: 47
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: Centos 6.8, Centos 5.10
Posts: 17,294

Rep: Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358
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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Original Poster
Rep: Reputation: 47
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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Original Poster
Rep: Reputation: 47
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,033

Rep: Reputation: 69
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
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,676

Original Poster
Rep: Reputation: 47
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


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
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


All times are GMT -5. The time now is 07:01 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration