List AIX File Systems the Easy Way With the lsvgfs Command

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.

0 (0)
Article Rating (No Votes)
Rate this article
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to check VLAN ID number on AIX?
Viewed 12461 times since Mon, May 28, 2018
Replacing a failed disk (rootvg)
Viewed 2748 times since Mon, May 21, 2018
Script HW/SW AIX
Viewed 8776 times since Mon, Jun 4, 2018
Topics: AIX, System Admin↑ Export and import PuTTY sessions
Viewed 2743 times since Fri, Apr 19, 2019
AIX, Storage, System Admin↑ Identifying a Disk Bottleneck Using filemon
Viewed 9560 times since Fri, Apr 19, 2019
This document discusses a new feature implemented for JFS2 filesystems to prevent simultaneous mounting.
Viewed 2612 times since Sat, Jun 1, 2019
0516-404 allocpThis system cannot fulfill the allocation
Viewed 9820 times since Thu, Sep 20, 2018
AIX How to Investigate a System Reboot
Viewed 6098 times since Tue, Aug 14, 2018
Software management in AIX
Viewed 6561 times since Mon, Jun 25, 2018
Viewed 6283 times since Mon, Jul 16, 2018