AIX > Tips & Techniques > Miscellaneous

List AIX File Systems the Easy Way With the lsvgfs Command

Even for an IT guy, having a favorite AIX command seems pretty geeky. Nonetheless, I do have one. It’s the lsvgfs command, which allows you to list the file systems in a single volume group or list the files that belong to single volume group.

Here’s how it goes:

	lsvgfs rootvg

It's that easy. Not a lot of AIX users know about this command, which is unfortunate because you'd be surprised how often the need to list the file system mount points for just one volume group arises. (For instance, you may need to identify the file systems on the disks in a single volume group. It’s also pretty valuable if you need to deactivate an entire volume group.)

Admittedly, there are other ways to accomplish this sort of thing. Many people use the lsvg command with the –l flag:

	lsvg –l rootvg

The problem with this is it requires you to cleanse some information from the output. For example, lsvg –l lists all the logical volumes (LVs) -- not just the ones with file system mount points. So if you have LVs for a dump device or paging space or JFS logs, you must exclude them, perhaps with the grep command. Using lsvgfs is much easier.

A Building Block

If you keep the lsvgfs command handy, you’ll see what a valuable foundation it is for working on all the file systems for a single volume group.

For instance, the df command allows you to display only selected file systems by specifying their mount points:

	df /home /tmp /var

Using lsvgfs as a building block, you can display the file systems in a volume group – and only those file systems:

	df –g $(lsvgfs rootvg)

The –g flag on the df command displays sizes in gigabytes.

What if -- instead of file systems -- you want to list all of the files in a single volume group? You can do that using the find command.

As you know, the find command takes a directory for its starting point for its searches. For example, here’s how to list all the files called .profile that are under the / file system.

	find / -name .profile

However, using the / directory as a starting point effectively means you’re going to find every single file called “.profile” from the root directory ( / ) down. This means every single directory on the system. So even though it's not in the / file system (it's in /home), the above command would find:


To narrow your search to the file system that has its mount point as /, add the –xdev flag to find:

	find / -name .profile –xdev

Now, with find, you can add a series of starting directories all in one command. For example, to search through /, /home and /usr, you could do this:

	find / /home /usr –name .profile –xdev

Once again, that –xdev means that files we're searching for in the /usr file system won't traverse other file systems, even if their mount points are sub-directories of /usr. So, for example, if /usr/local is a separate file system, then the –xdev flag with find /usr will tell find not to search outside /usr.

Putting it All Together

Since the find command allows you to use a few starting directories, it can be combined with lsvgfs to list the files in a particular volume group:

	find $(lsvgfs rootvg) –xdev

In addition, other flags, such as –ls, can be used to return a long list of files that include file sizes and permissions.

If you're trying to determine why a file system in your rootvg is suddenly full, the –mmin flag can be used to search for files that have recently been modified. Here's the command to see what's changed in the past 10 minutes:

	find $(lsvgfs rootvg) –xdev –mmin -10 -ls

Maybe you’d like to find all the files in the datavg volume group that end with .log. Here’s one way to do this:

	find $(lsvgfs datavg) –xdev –name “*.log” -ls

I previously wrote about other find command options here. By combining these with the lsvgfs command, you can easily narrow down your searches for files without the need to do elaborate script work.

Geeky as it may be, I especially like having the lsvgfs command up my sleeve. It's easy to remember and very, very handy, particularly when you combine it with other commands such as find.

Anthony English is an AIX specialist based in Sydney, Australia.

Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.


Application Testing: Giving Users What They Need


Change Management: Approval Must Be Earned


Making Changes: Prudence and Discipline Always

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters