Skip to main content
NetApp Knowledgebase

What is maxdirsize?

Last Updated:


Applies to

  • ONTAP 9
  • Data ONTAP 8


  • Maxdir-size is the volume option that limits the maximum size to which a directory file can grow. It sets the maximum size (in K-Bytes) that a directory can grow. 
  • The following error message is displayed:

Sun Aug 19 00:17:28 EDT [wafl.dir.size.max:warning]: Directory reached the maxdirsize limit. Reduce the number of files or use the vol options command to increase this limit.

  • Most users do not need to change this setting.
    • This option is useful for environments where system users may grow a directory to a size that starts impacting system performance.
    • When a user tries to create a file in a directory that is at the limit, the system returns a ENOSPC error and fails the create.
  • NetApp recommends not setting this option larger than necessary, as certain directory operations require the entire directory to be memory resident.
    • Thus, these operations require loading the whole directory which at best takes time and in worst case would not be possible.
  • Note:
    • Maxdir-size is a volume option and is transferred when Snapmirroring a volume between different model platforms. 
    • If a volume is transferred from a lower memory platform (therefore, having a lower default maxdir-size) to a higher memory platform, if will retain the lower maxdir-size. 
    • If this error is received on a volume that has maxdir-size set lower than the platform default, then maxdir-size can safely be raised to the platform default.
  • The main purpose of the maxdir-size limit is performance. Scans through directories are linear.
    • On average, half of the directory size will need to be scanned for each lookup, which can be slow.
    • WAFL grows directory data structures as used.
    • However, once a directory grows, there is no way to reduce the directory structure short of deleting it and recreating it.
    • If a large number of files have been deleted from a directory, you can reduce the directory space by completing the following steps:
  1. Copy the files into a temporary directory.
  2. Delete the original directory.
  3. Rename the temporary directory with the original directory name.
  • If only a few files were deleted or the procedure did not help to decrease the directory file size, increase maxdir-size.
    • Please reference the ONTAP manual specific to your OS version for additional information.
  • If you encounter the following error message, increase the maxdir-size setting or reorganize existing files so they are not stored in a single directory:

Error message: [myvol@filer: wafl.dir.size.max:warning]: Directory [dir] has reached the maxdirsize limit. Please increase the maxdirsize by using the vol options command.

In Data ONTAP 8 (7 mode) the syntax is:

vol options volname maxdirsize {size in Kb}

In ONTAP 9 and above the Syntax is:

volume modify -vserver {NAME} -volume {NAME} -maxdir-size {size in bytes}

The following example set a maximum directory size of 60MB for a volume named vol1on a virtual server named svm1.

cluster1::*> volume modify vol1 -vserver svm1 -maxdir-size 60MB                      
Volume modify successful on volume: vol1
cluster1::*> volume show -volume vol1 -fields maxdir-size
  (volume show)
vserver volume maxdir-size
------- ------ -----------
svm1    vol1   60MB

Note: You need to have privilege level set to advanced to run the above command.

Which directory does maxdir-size refer to?
  • Maxdir-size refers to the size on disk that a directory file takes up.
    • On the filer (as in UNIX), a directory is a much like any other file, it also has a size. 
  • The mapping between a name (or in the case of CIFS, several name variations) and an inode number is stored in that disk space.
How to identify the quantity of maxdir-size used?
  • The size of the directory cannot exactly be determined on Windows, but it can be inferred from the number of files and the name lengths.
  • That is where the ~100k files number comes from for CIFS. It is about ~300k files if the directory is NFS only.
Is there a way to determine how big maxdir-size should be?
  • On a UNIX system, issue ls -kld on the directory in question. It will give you a size.
    • Note: We can change it to ls -ld but the output has to be divided by 1024 since -k  stands for "like --block-size=1K".
  • When that size hits the default values, new file creates will likely fail. 
  • New files may continue to be created if there is a background cleanup operation running (i.e. a snap delete).
  • Once you have hit this limit, it is recommended to increase the maxdir-size.
  • It is important to note again that you may only increase maxdir-size, therefore the basic rule of thumb is to increase maxdir-size in 2% increments, that is, by 2% of the current value and not the system memory.
What are the performance impacts of changing the size of maxdir-size?
  • Performance issues are hard to quantify, but easy to state in a general sense.
  • Lookups in a large directory consume lots of CPU.
  • Converting a large directory from NFS only to CIFS takes lots of resources over a long period of time.
  • An additional performance impact is that when a directory is loaded into memory, the entire directory tree is loaded.
  • Parts of it may fall out of memory through non-use, but there is a performance impact from reading from disk and finding space in-memory for the directory to be stored.
Do files and directories located in .snapshot need to be included in the calculation?
  • No, files and directories located in the snapshots do not need to be included in the calculation.
Is changing maxdir-size immediate?
  •  Yes, you can change maxdir-size on the fly to increase the directory size when the users are connected to the filer.
How does enabling the 'create_ucode' and 'convert_ucode' volume options affect maxdir-size?
  • Sometimes, this message also appears after enabling the 'create_ucode' and 'convert_ucode' volume options.

Error message: [myvol@filer: wafl.dir.size.max:warning]: Directory [dir] has reached the maxdirsize limit. Please increase the maxdirsize by using the vol options command.

  • Increasing maxdir-size may not solve the problem since the message is caused by the conversion of Unicode on the filer.
  • The snapshots on the filer are locking the filesystem from changes, so temporary files are being created when non-Unicode data is being accessed. 
  • In this case, delete the snapshots that were created before the 'convert_ucode' and 'create_ucode' options were enabled.
  • This allows the existing data to be converted to Unicode format without creating extra temporary data on the volume. Leave the 'convert_ucode' and 'create_ucode' options enabled.
  • Once the 'old' snapshots are deleted, the maxdir-size  need not be increased unless there is a lot of data and files in the directory.
If the storage system is upgraded, will maxdir-size be increased?
  • No.
    • Volumes retain their created maxdir size. 
    • To have an increased maxdir size after an upgrade, the volumes will need to be either recreated or manually modified to the appropriate maxdir size for the storage system.
If the volume is migrated from earlier releases of ONTAP, will maxdir-size be increased?
  • No.
    • Earlier Data ONTAP releases used the system memory size as the base for determining the maxdir-size.
    • Upon migration, the volumes will retain the maxdir-size can be increased as required.
Maxdirsize and FlexGroups
  • Not all constituent volumes in a flexgroup may encounter the maxdir-size limitation linearly (in the weighted round-robin design).
  • The fix remains the same for the constituent volume (or volumes) encountering the limitation.
  • Please see NetApp ONTAP FlexGroup Volumes beginning on page 27 for reference.