rsync giving "file name too long" errors with ecryptfs

7,512

As mentioned over on Unix StackExchange, the maximum filename in an ext4 system is 255 characters. Since you have encrypted filenames turned on with your destination eCryptfs filesystem, and since eCryptfs is just a layered filesystem on top of your ext4 filesystem, all file name path elements, once encrypted, must be less than 255 characters. Similarly, the full path of any of your encrypted file names must be less than 4096 characters.

It seems that at least one of your source files has a path and/or name which violates this limit.

A couple of options come to mind to allow rsync to be able to complete its work:

  1. Find all files in your source filesystem that have path elements longer than 143 characters (or total paths greater than, perhaps, two or three thousand characters) and rename them to have less than that. (143 pulled from the previously referenced Unix StackExchange post due to encrypted filename padding). This may or may not be possible, depending on if the files in question can be renamed which preserving the functionality that you need on your system.
  2. Turn off filename encryption on your eCryptfs system. Of course, you'll lose the anonymity of your files names, but this may be acceptable to you.
Share:
7,512

Related videos on Youtube

Rich Wales
Author by

Rich Wales

Updated on September 18, 2022

Comments

  • Rich Wales
    Rich Wales almost 2 years

    I'm trying to use rsync to make an archival copy of a file system. Most of the files are being copied OK. However, some files are failing to be copied with errors such as the following:

    rsync: recv_generator: failed to stat "/offsite/secure/backup/equality/image/home/.ecryptfs/richw/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWZCrxWC57ny9UTn1cFNZL5w.27.bkB806NyASyVhlkjDSj8409CPYuh4U--/ECRYPTFS_FNEK_ENCRYPTED.FWZCrxWC57ny9UTn1cFNZL5w.27.bkB806NyN3crxC.r7IEshHGdDkRwJU--/ECRYPTFS_FNEK_ENCRYPTED.FZZCrxWC57ny9UTn1cFNZL5w.27.bkB806NyAT1fljq1oLjEFLY7WuGBIKEQb0Lw-70GL..7i70mP89OnSy2Lg88XZ-s5bs2ugEt16Xwqzd.SS1Gn-sditaJ6k--": File name too long (36)
    

    Is there anything I can do to work around this problem?

    The source computer is running Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-122-generic x86_64), with a ZFS source file system.

    The destination computer is running Ubuntu 18.04 LTS (GNU/Linux 4.15.0-23-generic x86_64), with an ecryptfs file system on top of ext4.

    • Rich Wales
      Rich Wales about 6 years
      Note that I'm intentionally trying to copy raw files without regard to whether they can be mapped via ecryptfs on the source machine or not. If people are terminally confused over the fact that my error example here involves an ecryptfs source file, here is another example which doesn't involve ecryptfs: rsync: mkstemp "/offsite/secure/backup/slippers/image/home/shoes/.cache/sof‌​tware-center/rnrclie‌​nt/.reviews.ubuntu.c‌​om,reviews,api,1.0,r‌​eviews,filter,en,can‌​onical,precise,any,a‌​dobe-flashplugin,pag‌​e,3,helpful,,1a51e72‌​988ac31d9a640831a73b‌​83a11.8MHWc7" failed: File name too long (36)
  • Rich Wales
    Rich Wales about 6 years
    Thanks. Unfortunately, neither of the above options is feasible for me in this situation. Is there some other file system format other than ext4 which I could use on my target (archival disk) to allow a longer maximum file name length?
  • Taylor R
    Taylor R about 6 years
    As far as I am aware, almost all filesystems have a 255 byte filename character limit, unfortunately. I ran up against this issue years ago myself. That, along with the extra overhead of eCryptfs, prompted me to switch to block-based disk encryption with dm-crypt + LUKS (which is offered with new installs of Ubuntu 16 as "full disk encryption") rather than the stacked filesystem encryption that eCryptfs offers. You could use dm-crypt to do block-based encryption of your target disk, and you would not have to worry about filename lengths anymore.
  • Rich Wales
    Rich Wales about 6 years
    OK, thanks. On further reflection, I might be able to deal with ecryptfs without file name encryption (just data encryption) after all.
  • Taylor R
    Taylor R almost 6 years
    Terrific! Glad that my answer helped you.