On a remote server running Linux Ubuntu 16.04', I ran out of space while doing a tar file from a bunch of old .rar files (~150G), and now the end tar is 'corrupt'. That is when doing a
tar tf I get:
tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now
How can I fix this corrupted tar?
I've tried to:
- delete the truncated file from the tar (
tar --delete -f mycorruptedtar.tar offendingfile.ext)
- repair it by extracting the files that aren't corrupt and adding them to a new tar by doing
#!/bin/bash for file in $(tar -tf mycorruptedtar.tar); do if [ ! "$file" == "offendingfile.ext" ] then tar xf mycorruptedtar.tar $file tar rf newtar.tar $file --remove-files tar --delete -f mycorruptedtar.tar $file fi done
- I also tried using a hex editor to remove the last part of the file which I assume is where lies the problem, but I chickened out because I didn't know exactly how or what to fix and I didn't want to worsen things.