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
AIX rootvg Mirroring
Viewed 4417 times since Mon, May 21, 2018
Secure Secure Shell
Viewed 10426 times since Fri, Aug 21, 2020
How to deal with performance monitoring in AIX ?
Viewed 7688 times since Fri, May 25, 2018
A tcpdump Tutorial and Primer with Examples
Viewed 4866 times since Sun, Jun 17, 2018
Altering LVM Configuration When a Disk is Not in ODM Anymore
Viewed 2949 times since Mon, Jun 3, 2019
Awesome Command to show top 15 processes using memory on AIX
Viewed 23685 times since Thu, Nov 29, 2018
Installing a Interim Fix (APAR IV16587)
Viewed 2831 times since Tue, Jul 17, 2018
AIX FC Performance improvements for IBM AIX FC and FCoE device driver stacks
Viewed 5575 times since Fri, Jan 31, 2020
Installation of the Virtual I/O Server directly from the HMC
Viewed 20152 times since Tue, Jun 4, 2019
AIX routing - How Do I Compare ODM with the Current Routing Table?
Viewed 2524 times since Mon, Jul 29, 2019