Extrat tar “Cannot open: File name too long”

command linetar

I made a tar with a directory on a remote machine with:

tar -czvf

I scp it to my local machine, where I wanted to untar it:

tar -xzvf

But I get : Cannot open: File name too long

On my local machine on lubuntu 12.04 I have: tar (GNU tar) 1.26.

The remote machine is not accessible right now, I'll check the version after if needed.

I would like to extract without having to make a new tar, especially since the remote machine is offline.

And by the way if you know a way to make proper archive despite long name, I'll take it.

Best Answer

tar limit file names to 256 bytes (with GNU extensions). Linux File Systems support at least 256 bytes per file name. It means any file packed by tar may be extracted without error. So I suppose two causes:

  1. The tarball is corrupted, check it by:

    $ tar -tvf tarball.tar
    

    You will see some erros if any.

  2. You use a "virtual" file system like fusecompress or ecryptfs (with selective file copmpression/encryption) and your file name is a bit shorter or equal to the file system limit. The trick is when you mount a directory with fusecompress (for example) and create a file name foo.bar the virtual filesystem creates a file called foo.bar.gz and compress it transparently, but hides the real file name from you. And if you create a file with 254 byte name long you get an error because it will try to append a suffix to it.

    In this case simply extracting the tarball outside of the virtual file system should help:

    $ sudo mkdir /home/${USER}-temp
    $ sudo chown $USER /home/${USER}-temp
    $ tar -xvf tarball.tar -C /home/${USER}-temp
    

Anyway, try to trace it to get more information:

$ strace -o tar-strace.log tar -tf tarball.tar
$ ltrace -o tar-ltrace.log tar -tf tarball.tar
Related Question