The most common question I get about disk usage is about the IFS, specifically “what is using all the disk space allocated to it?” Most recently I was asked this question during a PTF install by the good people of RPL in Telford.
So, thanks to them for putting food on my table and I thought rather than just email them an answer, it might be useful to talk about it here and share some of the tools you have available to answer this question.
When it comes to disk space allocated to libraries, IBM i makes it pretty easy to work out which objects in which libraries are using the largest amount space. The built in Collect and Print options on the “Go DiskTasks” menu (RTVDSKINF / PRTDSKINF) allow you to find out what you need to know pretty quickly.
Pro Tip: Schedule one of these collections weekly and you’ll be able to produce ad-hoc reports in minutes. Go DiskTasks, Option 1 Collect Disk Space Information, then Option 2 Weekly, enter date and time for collection.
But when it comes to the IFS then this report is less useful, as it simply tells you how much space is being used by the IFS, not where and by what objects that usage is being consumed.
The PRTDSKINF example below is typical, it tells us a 400GB system has 13% of the total disk space is free disk and that 66% is being consumed by the IFS but that is where the information stops, there is no detail on how and where it is being used.
So how can you tell what’s eating your IFS
There are a number of ways, especially if you know where to start looking but if you really don’t know where to start or want the full level of detail, then in my opinion one of the oldest tools is still the best and that is QRYIFSLIB.
This free tool was originally created by IBM as part of the IFSTOOL set. It’s not shipped as part of the operating system but is simple to get and install. If this level of detail is what you need, then you can skip down to the section below on QRYIFSLIB and I’ll take you through how to get it and how I use it.
But if you’d like to see a few other options and maybe add an extra tool to your own arsenal, here are a few of the ones I use the most. These are all included in the base OS, reliable and generally quick and easy to use, especially if you have a suspect directory in mind.
EDTF Path Size
Let’s start with EDTF, this is an often underrated tool on IBM i and since v5.4 it’s not just a file editor, as it has a file manager baked in, that is often more useful than WRKLNK.
To get started just type EDTF ‘/*’ from any command line, you’ll get a screen similar to the one below.
If you want to know how big a directory is, use Option 6 Path Size as shown below:
In this case we can see the FCSwitch directory is made up of 50 subdirectories with 986 files in them taking 1,239MB.
ProTip: Notice that there is also a Recursive Delete function in here, ideal for easily deleting directories containing objects and sub directories.
RTVDIRINF / PRTDIRINF
Shipped as standard is the Retrieve Directory Information command. It reads through the IFS and places the results in a file which you can then report upon with the PRTDIRINF command. This would be ideal if you could target the entire IFS but sadly you cannot (this is where QRYIFSLIB scores big time), instead you have to nominate a starting directory.
In this example we target the same directory as before with a pair of Retrieve and Print Directory Info commands.
RTVDIRINF DIR(‘/fcswitch’) INFFILEPFX(FC) INFLIB(MyTempLib)
PRTDIRINF RPTTYPE(*DIR) SUBTREE(*NONE)
Below is a snippet from the spool file created. Here we see that FCSwitch is made up of 1036 objects consuming 1297MB.
Lies, damn Lies and Statistics. So this is where the fun starts, you will notice we looked at the same directory with two different tools and got two different answers. So which one’s right? Well this is IBM i, they both are.
- The object count in the PRTDIRINF does not distinguish between files and directories, they are added together.
- The disk usage in the PRTDIRINF is based on the allocated disk space rather than the actual file size.
It’s also worth noting that there are options to the print command where you can list the files in the directories but I’ll let you go and research those options yourself, I can’t take away all of you fun now can I J.
ProTip: Specify a temporary library in the INFLIB parameter, as the default will start to clutter up QUSRSYS with a set of files you easily forget to delete.
Use the IFS function of the GUI Navigator client (System i Navigator if you are old school) or why not try the new iNav web client as I have here. This one is very popular with customers who have a “Windows” guy looking after the storage on their IBM i.
Either way, simply select the folder you which to target and then select properties, sample output for the same directory as before below:
ProTip: If you use the new ACS client to launch the IBM Navigator client then it automatically logs you in using the user you authenticate the client with. This is a real time saver and it is more secure – bonus!
OK so let’s get to the real point on this article. This program is not part of the base operating system, so you will have to download and install it but don’t let that put you off, it is part of the IFSTOOL library that has been around for years, works all the way back to V4R5, no that’s not a typo, I really mean Version 4 Release 5!
To install this command,
- Download the IFSTOOL.SAVF. Save file image from one of IBM’s public ftp servers
- Create an empty library and save file to house the install image
CRTLIB IFSTOOL Text(‘Cool free IFS tools that help me do clever things’)
- FTP this file to your server (using your FTP tool of choice to overwrite the empty save we just created)
- Restore the object from the save file to the IFSTOOL libarary
RSTOBJ *ALL DDILLING *SAVF SAVF(IFSTOOL/IFSTOOL) RSTLIB(IFSTOOL)
Authors Personal Note: D DILLING of IBM, who ever you are, where ever you are, thank you for this tool!
Add IFSTOOL to your library list and call the QRYIFSLIB command to analyse you IFS usage and dump the output into file QGPL/QRYIFSLIB.
CALL PGM(QRYIFSLIB) PARM(‘/*’ ‘\s’ ‘\X:*NONLOCAL’)
In the example below we use three parameters:
- /* tells the tool to start looking in the root of the IFS
- \s tells the tool to search all subdirectories
- \X:*NONLOCAL is the clever parameter that says to ignore libraries, DLOs, Optical Volumes and QNTC Windows shares!
ProTip: You can still use this tool to target a specific directory by placing that directory name in parameter 1, if we were to use this to analyse the FCSwitch directory as we did before, parameter 1 would be ‘/FCSwitch’
Using the Output of QRYIFSLIB
You now have a single file QGPL/QRYIFSLIB containing the details of every object in the IFS including size and location.
If we go back to the beginning of this article, we had an example of a 400GB system that was 87% full and we could see that 66% of it was in the IFS but we had no idea where on the IFS this was being used and no idea where to start looking.
Let’s see how QRYIFSLIB could help us.
Well, now that you have all the data on IFS disk usage in a single file, so all we need to do is analyse it just like we would any other file on the system.
So, in the example below, I used Query/400 to
- Summarise the file to give me totals per directory
- Sort the summary into descending size sequence
- Include the following fields
- Directories Size – the total size if all the files in that directory
- Largest Single file – the size of the largest single file in that directory
- File Count – How many file are in each directory
Bingo! Instantly we can see that a series of directories in /ptfarchive containing a hundred files is taking around 243GB of our 400GB system. If we can get rid of some or all of them, then our disk space problem is history.
ProTip: You can download the output file QGPL/QRYIFSLIB to your PC and examine with your favourite spreadsheet
OK, it’s fairly obvious this example is deliberately simple but even if your system is not as cut and dry as this, at least you would know what was is being used and where. Knowledge like that is always the start of the solution.
And if you are thinking, I don’t have disk space problems, so why should I bother?
Well firstly, I’d like to thank you for having read this far, I do hope you had a nice cup of coffee to help pass the time but seriously, you are in the most powerful position of all.
You have the option to start proactively collecting and summarising this information now, capturing a base line of your “healthy” system. If you were to take a regular snapshot like this, you could get really clever and track disk usage over time and nip potential problems in the bud before they grow enough teeth to bite you!
You could even start to calculate when you are likely to need more disks and so actually budget for the update in a timely manner. My boys do this for our clients and it’s amazing how much more receptive someone is to being told they need to spend money next year rather than next week!
Nice to see you
We have some fabulous speakers including IBM’s own Dawn May and David Spurway as well as our own rather fabulous Andy Youens, Tracy Eastwood and more.
Hope to see you there, more details and registration information available at www.i-ug.co.uk