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.

  • 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/software-center/rnrclient/.reviews.ubuntu.com,reviews,api,1.0,reviews,filter,en,canonical,precise,any,adobe-flashplugin,page,3,helpful,,1a51e72988ac31d9a640831a73b83a11.8MHWc7" failed: File name too long (36) – Rich Wales Jun 25 '18 at 1:26

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.
  • 1
    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? – Rich Wales Jun 25 '18 at 2:58
  • 1
    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. – Taylor R Jun 25 '18 at 3:08
  • OK, thanks. On further reflection, I might be able to deal with ecryptfs without file name encryption (just data encryption) after all. – Rich Wales Jun 25 '18 at 5:44
  • Terrific! Glad that my answer helped you. – Taylor R Jun 26 '18 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.