What is the maximum file name length for NTFS file system?

Are there any filename or path length limits on Linux?

asked May 18, 2009 at 17:27

2

See the Wikipedia page about file systems comparison, especially in column Maximum filename length.

Here are some filename length limits in popular file systems:

BTRFS   255 bytes
exFAT   255 UTF-16 characters
ext2    255 bytes
ext3    255 bytes
ext3cow 255 bytes
ext4    255 bytes
FAT32   8.3 (255 UCS-2 code units with VFAT LFNs)
NTFS    255 characters
XFS     255 bytes

What is the maximum file name length for NTFS file system?

Jens Erat

1,4402 gold badges12 silver badges26 bronze badges

answered May 18, 2009 at 17:29

WerkkreWWerkkreW

5,9093 gold badges23 silver badges32 bronze badges

11

I've read here that path length limit is in system headers. File name length limit is there too. On my system it's file:

  /usr/src/linux-headers-2.6.38-10/include/linux/limits.h

and C-lang defines:

  #define NAME_MAX         255    /* # chars in a file name */
  #define PATH_MAX        4096    /* # chars in a path name including nul */

and some more.

Ladadadada

26k7 gold badges59 silver badges90 bronze badges

answered Aug 31, 2011 at 8:58

sfpsfp

1,1211 gold badge7 silver badges2 bronze badges

5

I refer to other answers, please upvote them.

Are there any filename or path length limits on Linux?

Yes, filename and pathname lengths are limited by :

  • file-system limits as stated by WerkkreW ;
  • constants defined in linux/limits.h as stated by sfp.

To dynamically get these properties:

  • Use functions pathconf and fpathconf as proposed by Michael Aaron Safyan
  • Create a filename (or pathname) longer and longer as explained by dogbane
  • Use the command getconf as proposed by tim that is also available on Linux:

    $ getconf NAME_MAX /mnt/sda2/
    255
    $ getconf PATH_MAX /mnt/sda3/
    4096
    

answered May 24, 2014 at 7:35

What is the maximum file name length for NTFS file system?

oHooHo

5251 gold badge6 silver badges14 bronze badges

1

And for the sake of saving time (and anchoring it to memory):

ext2, ext3, ext4, zfs: no pathname limits; 255 bytes filename limit.

3

Those are file system name lengths. "linux" itself has some too. For instance, from bits/stdio_lim.h:

# define FILENAME_MAX 4096

answered May 18, 2009 at 18:15

jj33jj33

11k1 gold badge36 silver badges50 bronze badges

9

There is no way to determine the maximum length of paths on Linux in a portable way. On my system:

$ getconf PATH_MAX / 
4096
$ getconf _POSIX_PATH_MAX / 
4096

But I can easily create paths much longer than 4096 characters. Instead see PATH_MAX as a lower bound. You are guaranteed to be able to create paths this long, but you might also be able to create much longer ones.

answered Mar 22, 2016 at 18:31

4

You should always use pathconf or some function like this to get the runtime value about the specified items, as this page said that:

It should be noted, however, that many of the listed limits are not invariant, and at runtime, the value of the limit may differ from those given in this header, for the following reasons:

  • The limit is pathname-dependent.

  • The limit differs between the compile and runtime machines.

For these reasons, an application may use the fpathconf(), pathconf(), and sysconf() functions to determine the actual value of a limit at runtime.

answered Jan 16, 2015 at 2:17

What is the maximum file name length for NTFS file system?

andyandy

1212 bronze badges

It's specified in the system limits.h header file.

Here is one of these files:

cat /usr/include/linux/limits.h

...
#define NAME_MAX         255    /* # chars in a file name */
#define PATH_MAX        4096    /* # chars in a path name including nul */
...

Here is where copies of this file are located and values they define:

find /usr | grep limits.h | xargs -I {} grep -H 'NAME_MAX' {}

Output:

...
/usr/include/linux/limits.h:#define NAME_MAX         255        /* # chars in a file name */
...

answered Dec 5, 2014 at 1:49

What is the maximum NTFS filename length?

The maximum filename length on a NTFS partition is 256 characters, and 11 characters on FAT (8 character name, . , 3 character extension).

What is the maximum file name length?

File path/directory length We recommend that you keep directory lengths under 255 characters. Maximum directory path length of 255 characters for Windows. Maximum file name length of 255 characters for Mac.

What is the maximum length of a file name in Windows?

Microsoft Windows has a MAX_PATH limit of ~256 characters. If the length of the path and filename combined exceed ~256 characters you will be able to see the path/files via the Windows Explorer, but may not be able to delete/move/rename these paths/files.

What is the maximum number of characters for naming a file?

Windows can handle file names of up to 260 characters in length, including the path to the file.