Or — Two cool techniques to find the largest IBM i IFS Folders
But first, what is the IFS?
The IBM i Integrated File System (IFS) is a component of the IBM i operating system. It provides a unified interface for accessing and managing different types of file systems, similar to those found in personal computers and UNIX systems.
The IFS is:
- Unified Access: IFS allows users and applications to interact with various file systems through a common interface, making it easier to manage files, directories, libraries, and objects.
- Stream I/O Support: It supports stream input/output, which is optimized for handling data streams, unlike traditional record-based I/O.
- Multiple File Systems: IFS includes several file systems, such as the root (/) file system, QOpenSys (compatible with UNIX standards), QSYS.LIB (library file system), QDLS (Document Library Services), and more.
- Integration: It integrates different storage management capabilities, providing a cohesive structure over all information stored on the system.
IBM i Integrated File System (IFS) folders are (essentially) a version of a WINDOWS FOLDER on the IBM i System.
Me – talking to someone who has no idea what i am writing about… but does use a windows pc
So, the IFS is super useful but has a few problems and exposures:
- Security Risks: Many installations have inappropriate file shares defined, such as read/write access to the root directory, which can expose the system to unauthorized access.
- Low Visibility: System administrators often struggle with visibility into what is new or old within the IFS. This can make it difficult to manage and clean up files, leading to clutter and potential space issues.
- Complexity: The IFS interface is optimized for stream data input/output, which can be more complex to manage compared to traditional record-based input/output systems.
- Maintenance Challenges: Regular maintenance, such as cleaning up PTFs (Program Temporary Fixes) and document files, is often neglected until space becomes critically low.
These issues can make managing IFS folders challenging, especially for those not familiar with its intricacies.
As we are talking about FAT FOLDERS let’s have a little peek into the MAINTENANCE CHALLENGES of keeping our IFS neat and tidy.
How to find the fattest IFS Folders?
To determine which IBM i IFS folders are using the most space, we have lots of different techniques. My favorite two would be:
(1) RTVDIRINF – Retrieve Directory Information
- Submit a job to retrieve directory information for all user directories
- This command will gather information about the root and all nested sub-directories and store it in the database files
MYROOTDIRO
andMYROOTDIRD
in theQUSRSYS
library - Use SQL to query the collected data.
Let’s start by using the RTVDIRINF
command:
SBMJOB CMD (RTVDIRINF DIR ('/HOME') INFFILEPFX (MYROOTDIR) SUBTREE (*ALL) OMIT ('/QNTC' '/QFilesvr.400' '/QDLS' '/QSYS.lib')) JOB (RTVDIRINF)
When this runs it will create two files and tell you in the joblog like this:
RTVDIRINF DIR('/home') OMIT('/QNTC' '/QFilesvr.400' '/QDLS' '/QSYS.lib')
Database files QAEZD0001O and QAEZD0001D created in library QUSRSYS.
Directory information was successfully retrieved.
So now we can use SQL to query those output files to see the total size retrieved for /HOME and all subdirectories you can use:
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.QAEZD0001O ;
Now you can review the output to identify which directories are using the most space.
How to decide which directories or files to clean up?
To list directories with the largest sizes first, use:
select sum(O.QEZALCSIZE),
D.QEZDIRNAM1,
D.QEZDIRIDX
from QUSRSYS.QAEZD0001D D
join QUSRSYS.QAEZD0001O O
on D.QEZDIRIDX = O.QEZDIRIDX
group by D.QEZDIRIDX,
QEZDIRNAM1
order by 1 desc, 3, 2;
which will show you all the subfolders – with their sizes from your starting folder down:
Having said all this, my favorite way to manage space usage in IBM i IFS is to use a quick little SQL statement which uses the very clever IBMVIEW called ‘IFS_OBJECT_STATISTICS’
(1) SQL – Use QSYS2.IFS_OBJECT_STATISTICS
The QSYS2.IFS_OBJECT_STATISTICS
table function in IBM i returns a table of objects contained in or accessible from a specified starting path in the Integrated File System (IFS). This function is useful for retrieving detailed information about files and directories, similar to what you would get from the Retrieve Directory Information (RTVDIRINF) command or the Qp0lGetAttr() API.
Here are some key parameters you can use with this function:
- START_PATH_NAME: Specifies the starting path for the search.
- SUBTREE_DIRECTORIES: Indicates whether to process all subdirectories recursively.
- OBJECT_TYPE_LIST: Lists the types of objects to be returned.
- OMIT_LIST: Specifies paths to exclude from processing.
- IGNORE_ERRORS: Determines whether to ignore errors encountered during processing.
So all you have to do is type this into SQL:
select PATH_NAME,
DATA_SIZE
from table (
QSYS2.IFS_OBJECT_STATISTICS('/home', 'YES', '*ALLSTMF')
)
where DATA_SIZE > 1024
order by DATA_SIZE desc
In this example I am saying ‘show me the IFS FOLDER OBJECTS within /HOME with sizes greater than a megabyte’
And there you have it!
Clean up my IBM i IFS Two Ways 🙂