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?
-
I can have file names that are 145 bytes.– TimFeb 1, 2016 at 20:52
-
Hi! Do you use file system encryption on your system?– Armand BozsikFeb 1, 2016 at 20:54
-
To test the file name limit see stackoverflow.com/questions/6571435/… - my Ubuntu ext4 has a limit of 255 as expected. Also related: askubuntu.com/questions/166764/how-long-can-file-names-be– TakkatFeb 1, 2016 at 21:02
-
@ArmandBozsik that appears to be the cause. Is there a way to increase the file name limit in an encrypted directory?– BipedalSharkFeb 1, 2016 at 21:06
-
1You're using eCryptfs? EncFS may have a different limit, or a fixed size LUKS container could use regular ext... Or, not using filename encryption may change the limit– Xen2050Feb 2, 2016 at 2:10
1 Answer
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 :)