IBM Support

How to Locate Which "User directories" are Using the Most Space in the IFS

Question & Answer


Question

If IBM i DASD usage is increasing, IBM i administrators should quickly determine where the large (or many) files or directories are located. This document addresses how to find which user directories are using the most space in the IFS.

Answer

Collect and review a disk report. See GO DISKTASKS Overview

Once a disk report summary has been gathered, print it with:
PRTDSKINF RPTTYPE(*SYS)
Review the resulting QPEZDISK spooled file output. If the "User directories" value is high, information regarding the storage allocated to the user directories should be retrieved. This will show specifically which user directories have allocated the most space.

First, a job is submitted which executes RTVDIRINF on all user directories on the system. The operation may take some time, depending on many system configuration and usage variables:
SBMJOB CMD(RTVDIRINF DIR('/') INFFILEPFX(MYROOTDIR) SUBTREE(*ALL) OMIT('/QNTC' '/QFilesvr.400' '/QDLS' '/QSYS.lib')) JOB(RTVDIRINF)

The above command retrieves directory information regarding the root and all nested sub-directories and stores it in the database files MYROOTDIRO and MYROOTDIRD in library QUSRSYS.

Notes:
1. If a particular user directory (For example, /tmp) is suspected of allocating a lot of space, time can be saved by running the RTVDIRINF on that specific directory instead ((RTVDIRINF DIR('/tmp')).
2. Any NFS mount points should be added to the omit list as well.
3. Check the joblog of the submitted RTVDIRINF job for any success or failure messages.

When finished successfully, the following message will be in the submitted job log:
  • "Database files MYROOTDIRO and MYROOTDIRD created in library QUSRSYS. "

The "O" (Objects) and "D" (Directories) tables are then queried using an SQL interface such as IBM Access Client Solutions' "Run SQL Scripts" function.

To see total size retrieved within the SQL session, issue the following SQL statement:
  SELECT 
sum(QEZALCSIZE) as "Number of bytes allocated for the object", 
sum(QEZDTASIZE) as "Size in bytes of the data in the object" 
FROM QUSRSYS.MyRootDirO;

For a listing of directories with the largest directories listed first, issue the following SQL statement:
  SELECT sum(O.QEZALCSIZE), D.QEZDIRNAM1, D.QEZDIRIDX  
FROM QUSRSYS.MyRootDirD d join QUSRSYS.MyRootDirO o on d.qezdiridx = o.qezdiridx  
GROUP BY d.qezdiridx, qezdirnam1  
ORDER BY 1 desc, 3, 2;

Sample output when the above SQL statements were run using Access Client Solutions "Run SQL Scripts" functionality :

In the example above, disk cleanup could start with the user directory "/rick" and proceed down the list.

Below is an example to delete everything within directory '/rick' including all sub-directories and files:

 ===> RMDIR DIR('/rick/*') SUBTREE(*ALL)

***Use with caution!*** The above is functionally equivalent to the POSIX command "rm -rf /rick/*".  ***Use with caution!***

Note: IBM i Access Client Solutions, "Run SQL Scripts" function includes several IFS-related example scripts. They are available under the pull-down menu "Edit -> Insert from Examples..." and then search on "IFS"

Note: Once you have found and addressed the IFS directories, consider deleting the files holding the IFS directory information using SQL statement:

drop table qusrsys.MyRootDirO;
drop table qusrsys.MyRootDirD;

Note: To determine the size of a single, known directory, from a PASE, QSH, or SSH command prompt, execute:

du -sh /path/to/directory

Assistance creating customized SQL statements can be obtained via IBM i Customized Services.


 

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Component":"Not Applicable","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB68","label":"Power HW"}}]

Document Information

Modified date:
17 June 2024

UID

nas8N1021607