Skip to main content
NetApp Knowledge Base

What is directory size?

Views:
5,145
Visibility:
Public
Votes:
2
Category:
ontap-9
Specialty:
core
Last Updated:

Applies to

  • ONTAP
  • Directory

Answer

Note:  The phrase, "directory size" in this context does not apply to the total disk space used by the contents of all of the files in a given directory.  

To understand directory size, we first need to understand what a directory actually is. There are typically three major types of files in a Unix type operating system: 

  • Regular File
  • Special File
  • Directory File

Regular files contain data created by users and applications. For Special files see File types In Linux/Unix explained in detail.  This article discusses Directory files.

What is a Directory File?

File systems track name, location, and other metadata for every file. If this metadata was only in the inode or the file itself, it would take an extreme length of time reading from disk to locate a file. To mitigate this performance problem, file names and other needed metadata is kept in a single file called a Directory file.

Note: See "Additional Information" below for examples of some of the file metadata contents of a file and also  What is an inode?

Some of the contents of a Directory File includes:

  • File name
  • DOS 8.3 name, if created with CIFS
  • Inode number 
How to find the size of a Directory File

The size of the Directory File becomes important in environments with high file counts in a single directory.  Modern file systems allow for long file names and a high number of files in a directory.  Both the length of the file names, and the number of files in a single directory contribute to Directory File size.

To see Directory File size, use the following command from a client: 

$ ls -l
-rwxr-xr-x  1 user group      98404 Nov  8  2021 application.png      
drwxr-xr-x  3 user group       4096 Apr 13  2022 backup
-rw-rw-r--  1 user group    2221823 Aug 30  2021 ems.log.0000000009.txt   
-rwxr-xr-x  1 user group    1174298 Feb 12  2020 putty.log
drwxrwxr-x  4 user group      12288 Sep 17  2021 logs

  • The fifth column in this output shows the space used for each file.
  • The highlighed entries are the size of the directory file in bytes.
  • The default size of a newly created directory is 4096 bytes.
What is considered large for Directory File? 

In ONTAP, a Directory File size of 2MiB or greater is considered large for searching. Directory files of this size and larger are automatically indexed to improve search performance.

Additional Information

$ stat file.dat
  File: file.dat
  Size: 419430400       Blocks: 822432     IO Block: 65536  regular file   
Device: 3bh/59d Inode: 99629125    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1010/user)   Gid: (   80/    grp)
Context: system_u:object_r:nfs_t:s0
Access: 2017-01-16 04:54:15.115626000 -0800
Modify: 2013-01-09 02:48:00.000000000 -0800
Change: 2017-01-16 04:54:15.116631000 -0800
 Birth: -

  • Example of directory file metadata

  $ stat fspopulate
  File: fspopulate
  Size: 4096            Blocks: 8          IO Block: 32768  directory      
Device: 3bh/59d Inode: 89991994    Links: 4
Access: (2755/drwxr-sr-x)  Uid: ( 1010/user)   Gid: (   80/    grp)
Context: system_u:object_r:nfs_t:s0
Access: 2022-05-30 03:45:53.110149000 -0700
Modify: 2017-01-16 04:54:15.538648000 -0800
Change: 2017-01-16 04:54:15.538648000 -0800
 Birth: -

 

NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.

 

  • Was this article helpful?