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:

	/home/anthony/.profile

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
Attachments
There are no attachments for this article.
Comments
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
Awesome Command to show top 15 processes using memory on AIX
Viewed 23347 times since Thu, Nov 29, 2018
AIX disk queue depth tuning for performance
Viewed 14567 times since Thu, Jan 16, 2020
Check connection (rsh or nimsh) between NIM server and LPAR
Viewed 9069 times since Thu, Feb 21, 2019
0516-404 allocp: This system cannot fulfill the allocation request. [AIX]
Viewed 4674 times since Thu, Sep 20, 2018
Using AIX VG mirroring in combination with hardware snapshots
Viewed 4592 times since Sat, May 25, 2019
Script to reset NIM state and deallocate resources
Viewed 2088 times since Thu, Feb 21, 2019
VIO Server Howto
Viewed 9564 times since Mon, Jun 11, 2018
How to Backup and Upgrade a Virtual I/O Server Part I
Viewed 4081 times since Wed, Jun 5, 2019
Getting bosboot errors, don’t reboot just yet
Viewed 2628 times since Tue, Apr 16, 2019
AIX www web Links
Viewed 2983 times since Fri, Apr 19, 2019