Skip to main content
ONTAP Technical Reports

View maxdir-size and current directory size

Contributors whyistheinternetbroken

The volume maxdir-size field is the authorized cap for every directory in the volume. Measuring an individual directory requires inspecting that directory object, not the volume's data used.

View the configured cap

set -privilege advanced
volume show -vserver <svm> -volume <volume> -fields maxdir-size

This reports the per-directory cap, not the size of a particular directory.

View the directory file from an NFS client

There are no ONTAP commands that report an individual directory's size directly, so the value must be queried from a client or with an off-box tool. An NFS client is the preferred client-side method when exact directory-object size is required.

On a mounted NFS path from a GNU/Linux client, use stat or a long directory listing on the directory object itself:

stat -c '%n %s bytes' /mount/path/directory
ls -ld /mount/path/directory

Do not use du for this purpose. du reports data reachable below the directory, whereas maxdir-size applies to the directory metadata file itself.

To find the largest directories under a mount point, run a find that lists leaf directories by size and prunes Snapshot copies. The following returns the 10 largest directories:

find /mountpoint -name .snapshot -prune -o -type d -ls -links 2 -prune | sort -rn -k 7 | head

The seventh column is the directory-file size in bytes; a directory at the 320 MB default appears as 335,544,320 bytes. This runs quickly even on directories with millions of files.

View directory size from an SMB client

Windows and SMB clients do not expose a directory's own metadata size, so there is no direct SMB equivalent of stat or ls -ld for maxdir-size:

  • dir lists a directory as <DIR> with no size of its own.

  • A folder's Properties dialog in File Explorer reports the total size of the data contained below the folder (equivalent to du), not the directory metadata file.

To measure directory size for an SMB-served dataset, use one of the following instead:

  • If the volume also allows NFS, mount it and use the stat, ls -ld, or find methods above.

  • Use NetApp XCP, which can scan an SMB share directly (see the following section).

Scan directory sizes with XCP

NetApp XCP scans a file system in parallel and reports directory sizes and counts, which is useful for large or FlexGroup datasets. It works against both NFS exports and SMB shares. XCP scans the entire file system before returning matches, so allow time on high-file-count datasets.

Note XCP 1.5 reorganized the tool into subcommands such as scan and diag. Use the xcp scan form on XCP 1.5 and later. On earlier releases, run the same -match and -fmt options directly without the scan verb, for example xcp -match "type == d" -fmt "…​" <host>:/<export>.

Print a tree-statistics report, which includes the largest directory's entry count (shown as Dirsize) along with file and directory counts:

xcp scan -stats <host>:/<export>

List each directory with its directory-file size in bytes, largest first. For a directory object, the used value is the directory metadata size that maxdir-size caps:

xcp scan -match "type == d" -fmt "'{} {}'.format(used, x)" <host>:/<export> | sort -rn

Add -csv or -html to save an exact-value report instead of the abbreviated console totals.

To restrict the scan to directories above a chosen entry count, use xcp diag find. The following example lists directories with more than 2,000 entries (adapted from TR-4571: NetApp ONTAP FlexGroup volumes):

xcp diag find --branch-match True -fmt "'{size} {name}'.format(size=x.digest, name=x)" <host>:/<export> 2>/dev/null | awk '{if ($1 > 2000) print $1 " " $2}'

Locate a directory reported by EMS

The maxdir-size EMS event includes a volume and file ID. Resolve that inode to a path with:

volume file show-inode -vserver <svm> -volume <volume-or-constituent> -inode-number <file-id>

The reported file ID belongs to the directory that reached or approached the limit, not to the file whose creation failed.

Note For a FlexGroup, volume file show-inode operates on a constituent rather than the FlexGroup name. Use the constituent named by the EMS event, such as fg__0024.

← Previous: Maxdir-size and large ONTAP directories

Next: Directory indexing in ONTAP →