How can I increase Ubuntu's 143-byte file name limit for encrypted directories?

In encrypted directories, Ubuntu (at least 15.10) seems to have a file name byte limit of 143 B--much smaller than the ext4 file system's limit of 255 B. Where is this special limit set, why is it set in the first place, and is there a way to increase it?


Solution 1:

Where is the Ubuntu limit set,

It is a filesystem limit. All "ext" have a 255 chars limit. Here is a list of a lot of filesystems. ReiserFS shows 4032 bytes (but it is limited to 255 chars because of Linux VFS).

The 144 char limit for encypted file is incorrect. It is 143 (from the creator of ecryptfs utilities). The remaining chars are needed for the encrypting so you can not go over it (encryption does not work on files with more than 143 chars).

and is there a way to increase it?

No


Some more info. These will show file and directory size limit in chars:

 getconf NAME_MAX /dev/sda
 getconf PATH_MAX /dev/sda

See /usr/include/linux/limits.h for the declaration of these 2 variables:

#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

#define NR_OPEN         1024

#define NGROUPS_MAX    65536    /* supplemental group IDs are available */
#define ARG_MAX       131072    /* # bytes of args + environ for exec() */
#define LINK_MAX         127    /* # links a file may have */
#define MAX_CANON        255    /* size of the canonical input queue */
#define MAX_INPUT        255    /* size of the type-ahead buffer */
#define NAME_MAX         255    /* # chars in a file name */
#define PATH_MAX        4096    /* # chars in a path name including nul */
#define PIPE_BUF        4096    /* # bytes in atomic write to a pipe */
#define XATTR_NAME_MAX   255    /* # chars in an extended attribute name */
#define XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */
#define XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */

#define RTSIG_MAX     32

#endif

You can change this value but you will need to recompile at least the fopen() function for it to be usable. And there will be no compatibility with any other operating systems.

So I change my answer to: Yes you can but please do not :)