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
replacing (hot-swap) failed disk in rootvg
Viewed 8529 times since Thu, Sep 20, 2018
Mirroring session (TTY) on AIX using portmir
Viewed 8694 times since Thu, Feb 21, 2019
HMC: HMC and LPAR management commands
Viewed 6393 times since Sun, Jun 3, 2018
The new VIOS performance advisor tool part util
Viewed 2777 times since Tue, Jun 4, 2019
LVM: Unmirror/Mirror "rootvg" Volume Group
Viewed 2966 times since Mon, May 21, 2018
Create memory resident filesystems (RAM disk) on AIX
Viewed 2282 times since Thu, Feb 21, 2019
n a perfect world....rootvg would always reside on hdisk0
Viewed 1930 times since Thu, Jun 6, 2019
Firmware Assisted Dump sysdump
Viewed 1640 times since Mon, Jul 16, 2018
AIX routing - How Do I Compare ODM with the Current Routing Table?
Viewed 2151 times since Mon, Jul 29, 2019
Technology level update on AIX using smit_update and alt_disk_install method
Viewed 5053 times since Sun, Jun 30, 2019