Operating System - HP-UX
1833887 Members
1766 Online
110063 Solutions
New Discussion

BDF logical volumes display

 
SOLVED
Go to solution
MAD_2
Super Advisor

BDF logical volumes display

I have two systems where the display from bdf is used to create some daily logs. However, I have a problem while running my scripts because the "file systems" are displayed in one order in one system and in another order in the other.

Here's how they display the bdf output:

HP1 System Log
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 143360 47534 89871 35% /
/dev/vg00/lvol1 196656 30688 146296 17% /stand
/dev/vg00/lvol8 1089536 562640 494061 53% /var
/dev/vg00/lvol7 1048576 649530 374123 63% /usr
/dev/vg00/lvol6 106496 7218 93831 7% /tmp
/dev/vg03/oradata2 8192000 6671632 1425537 82% /oradata2
/dev/vg02/ordata1 4096000 3100339 947599 77% /oradata1
/dev/vg01/oradata 8380416 7468473 858090 90% /oradata
/dev/vg00/lvol4 24576 21483 2942 88% /home
/dev/vg05/lvol1 12288000 9641436 2481158 80% /data2
/dev/vg04/lvol2 6348800 2571811 3540965 42% /data
/dev/vg05/oracle 2818048 2332313 455432 84% /oracle
/dev/vg00/lvol5 921600 834423 81738 91% /opt


HP2 System Log
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 204800 141829 59074 71% /
/dev/vg00/lvol1 303125 31737 241075 12% /stand
/dev/vg00/lvol8 1245184 835628 384253 69% /var
/dev/vg00/lvol7 1384448 958665 399426 71% /usr
/dev/vg00/lvol4 600000 32581 533177 6% /tmp
/dev/vg01/oradata2 8224768 5475182 2577741 68% /oradata2
/dev/vg01/oradata1 8224768 4508323 3484278 56% /oradata1
/dev/vg01/oradata 8224768 5654406 2409718 70% /oradata
/dev/vg01/oracle 6160384 2403001 3522567 41% /oracle
/dev/vg00/lvol6 761856 533108 214461 71% /opt
/dev/vg00/lvol5 24576 6809 16723 29% /home
/dev/vg01/data2 18448384 12445708 6002676 67% /data2
/dev/vg01/data 6160384 21690 5755526 0% /data

I want the file systems in HP1 to display in the same order as that displayed by HP2 (the last one). I can temporarily fix it by editing /etc/mnttab. However I must do this very often in order to get them to display the same way to grab the information resulting from the command. I would like a permanent solution.

Order wanted:

/
/stand
/var
/usr
/tmp
/oradata2
/oradata1
/oradata
/oracle
/opt
/home
/data2
/data

Any ideas? Thanks!
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: BDF logical volumes display

The easiest way would be to hardcode it in your script.

Something like:

FILESYSTEMS="/ /stand /var /usr /tmp /oradata2 /oradata1 /oradata /oracle /opt /home /data2 /data"

bdf $FILESYSTEMS


There is no way I know of to have a specific order to the display the LVs when doing a bdf.
Caesar_3
Esteemed Contributor

Re: BDF logical volumes display

Hello!

Check the /etc/fstab you can control on the order from there.
But if you want that will shown in the same
order on the two machines and they always
have the same mounts

Then try : bdf | grep ^\/dev\/vg | sort

Caesar
MAD_2
Super Advisor

Re: BDF logical volumes display

Caesar, actually what is controlling the order in which bdf displays is "/etc/mnttab". But when I change it, it only stays the way I want it for a short while and not permanently.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Ronelle van Niekerk
Regular Advisor
Solution

Re: BDF logical volumes display

I would pipe the bdf through a sort - but be sure to sort on the filesystem name:

bdf | sort -k 6
rm -r /it/managers
Bill Hassell
Honored Contributor

Re: BDF logical volumes display

There is no way to control the order of the mounted volumes, nor would you want to by manipulating mnttab. As mentioned, simply sort the bdf output. Since the source volume groups and lvols do not match, just sort on field 6 (the mount point):

bdf -l | sort -k6

That way, regardless of how each system is changed, the mountpoints will always be in the same sorted order.


Bill Hassell, sysadmin
Michael Tully
Honored Contributor

Re: BDF logical volumes display

One further footnote to this.

If you have filesystems that wrap onto an additional line, then running

$ bdf -i | sort -k6

will not work. Patricks suggestion to run the names into a variable will work well.
Anyone for a Mutiny ?
Bill Hassell
Honored Contributor

Re: BDF logical volumes display

Actually, bdf will breakup into 2 lines whenever the source device file for the mountpoint is too long. Usually, this is due to NFS sources but a really long VG and lvol name will cause this break to occur. Since this is not a dependable break point, the following script will handle any one or 2 line bdf output. In this example, bdf -l (-l means local filesystems, no NFS) is fed into a read with enumerated variables for each column. If the first read does not assign a value to TOT then a 2-line bdf list is ocurring so read the missing items. The following will handle any arbitrary source file and always output 1 line for each mounpoint:

bdf -l |
while read FS TOT USED AVAIL PERCENT MNT
do
if [ "$TOT" = "" ]
then
read TOT USED AVAIL PERCENT MNT
fi
print $FS $TOT $USED $AVAIL $PERCENT $MNT
done | sort -k6


Bill Hassell, sysadmin
Sunil Sharma_1
Honored Contributor

Re: BDF logical volumes display

Hi,

There is no way you can do it with single command, as you said it's controled by mnttab file.
so best way is the use some script suggeted by other sysadmins.

Sunil
*** Dream as if you'll live forever. Live as if you'll die today ***
MAD_2
Super Advisor

Re: BDF logical volumes display

Sorry it took me so long to return to this one... However, I have assigned some points already. The bdf | sort -k6 works for me a this moment. None of my lines wrap, so the solution suits me well in this environment.

Thanks everyone for your replies, and sorry for the long, very long delay to reply.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with