Visualize the Physical Layout of an AIX Volume Group

From: Brian Smith’s AIX / UNIX / Linux / Open Source blog

9/23/13 Update – See this updated verison of the script as well.  

Here is a script I’ve written to visualize the physical layout of an AIX volume group.   The script visually shows the location of every Physical Partition (PP) on each hdisk (AKA Physical Volume).   The output shows which Logical Volume (LV) is on each of the PP’s (or if it is free space).   The output is color coded so each LV has its own color so that it is very easy to see where each LV physically is across the entire Volume Group.  You can specify the number of columns of output depending on the size of your screen.

The intended use of the script is to show a visual representation of the Volume Group to make using commands which move around LP’s/PP’s such as migratelp easier to use, to make LVM/disk maintenance easier, and also as a learning tool.

Here are a few screenshots:




  When running the script you specify 2 parameters:  The volume group name, and the number of columns you would like displayed (or it will default to 3 columns if not specified).

Here is the script:


#vvg - visualize physical layout of AIX volume group
#Copyright Brian Smith, 2013

set -A colors 41m 42m 43m 44m 45m 46m 47m 100m 101m 102m 103m 104m 105m 106m
tempfile=”/tmp/`basename $0`_$$”
tempfile2=”/tmp/`basename $0`_2$$”
> $tempfile
> $tempfile2

if [ -n “$1” ]; then
echo “Specify VG name as first parameter”
exit 1

if ! lsvg $vg >/dev/null 2>&1; then
echo “Error: VG name not correct or VG not varried on”
exit 2

[ -n “$2” ] && col=$2 || col=3
if ! echo $col | grep “^[0-9]*$” >/dev/null || [ “$col” -eq 0 ]; then
echo “Error: second parameter should be number of columns”
exit 3

while [ “$count” -lt “$col” ]; do
columns=”$columns -”
count=`expr $count + 1`

. $tempfile
. $tempfile2
[ “$index” -gt 0 ] && index=`expr $index + 1`
lspv -M $pv | while read line; do
if echo $line |  awk ‘NF==1 {print}’ | grep ‘-‘ >/dev/null; then
                    beg=`echo $line | awk -F: ‘{print $2}’ | awk -F ‘-‘ ‘{print $1}’`
                    end=`echo $line | awk -F: ‘{print $2}’ | awk -F ‘-‘ ‘{print $2}’`
                    while [ “$beg” -le “$end” ]; do
                            echo “${pv}:$beg Free”
                            beg=`expr $beg + 1`
elif echo $line | awk -F: ‘{print $2}’ | grep “^[0-9]*$” >/dev/null ; then
                    echo “$line Free”
                    echo “$line”
done | while read line2; do
pp=`echo “$line2” | awk ‘{print $1}’ | awk -F: ‘{print $2}’`
lv=`echo “$line2” | awk ‘{print $2}’ | awk -F: ‘{print $1}’`
lp=`echo “$line2″ | awk ‘{print $2}’ | awk -F: ‘{print $2}’`

eval if ! [ -n \”\$${lv}\” ]\; then \
                    ${lv}=$index\;        \
                    echo ${lv}=$index \>\> $tempfile  \; \
                    index=`expr $index + 1`\;   \
                    [ \”\$index\” -gt \”13\” ] \&\& index=0 \; \
                    echo index=$index \> $tempfile2  \; \
eval printf  \\\\033[\${colors[\$${lv}]}
if [ -n “$lp” ]; then
                    printf “%-7s %-15s %+7s\033[0m ” “PP$pp” “$lv” “LP$lp”
                    printf “%-7s %-23s\033[0m ” “PP$pp” “$lv”
done | paste -d ” ” $columns

for pv in `lspv | grep ” $vg ” | awk ‘{print $1}’`; do
ppsize=`lspv $pv | grep “^PP SIZE” | awk ‘{print $3 ” ” $4}’`
echo “\033[1;36m******************************* \033[0m”
printf “\033[1;36m* %-8s                    * \n\033[0m” $pv
printf “\033[1;36m* Size   : %-10s         * \n\033[0m” “`getconf DISK_SIZE /dev/$pv` MB”
printf “\033[1;36m* PP Size: %-19s* \n\033[0m” “$ppsize”
echo “\033[1;36m******************************* \033[0m”
showdisk $pv
rm $tempfile
rm $tempfile2

AIX Tips & tricks


AIX Tips & tricks 

Below are few of the AIX commands which will be useful for AIX admins.

1. To list machines configured in a NIM Server,
# lsnim -c machines

2. To list networks configured in a NIM Server,
# lsnim -c networks

3. To reset a machine (return to ready state)
# nim -Fo reset MachineName

4. To list core file settings for a user,
# lscore user1

The output will look like:
compression: on
path specification: default
corefile location: default
naming specification: off

5. To list the default settings for the system,

# lscore -d

The output will look like:
compression: off
path specification: on
corefile location: /corefiles
naming specification: off

6. To make any process run by root dump compressed core files and restore the location of the core files to the system default,

# chcore -c on -p default root
Note: If no default is specified, cores will dump in the current directory.

7. To enable a default core path for the system, type:

# chcore -p on -l /corefiles -d

8. To scan logical volume lv01, report the status of each partition, and have every block of each partition read to determine whether it is capableof performing I/O operations, type:

# mirscan -l lv01

9. To do the above operation in a PV,

# mirscan -p hdisk1

10. To do the above operation in a VG,

# mirscan -v vg01

11. To determine if the 64-bit kernel extension is loaded,

# genkex grep 64

12. To list all JFS file systems,

# lsjfs

13. To list all JFS2 file systems

# lsjfs2

14. To mirror a terminal1 on terminal2
a. Open terminal 1 and find the pts value (ps -ef grep pts)

b. Open terminal 2 and enter ‘portmir -t pts/1’
c. Now you will see commands and outputs from terminal 1 in terminal 2.
This is basically monitor a terminal.
d. Say “portmir -o” to end the mirroring after the use

15. To identify the current run level,

# cat /etc/.init.state

16. To list the available CD ROM drives,

# lsdev -Cc cdrom

17. To find out the speed of your network adapter,

# entstat -d ent0 grep “Media Speed”

18. To find out when your system was last installed/updated

# lslpp -f bos.rte

19. To list the status of your tape drive,

# tctl -f /dev/rmt0 status

20. How to setup anonymous ftp in AIX

Run the below script to setup anon ftp,
# /usr/lpp/tcpip/samples/anon.ftp

21. If telnet takes more time to produce a prompt, do the below checks

a. do nslookup of the client ip from the aix serverb.
b. Check the nameservers in /etc/resolv.confc.
c. Check the ‘hosts’ entry in /etc/netsvc.conf or NSORDER variable

This issue might be due to the DNS configuration issue. Pointing to a good nameserver should solve the problem.

22. How to shutdown the system to maintenance mode ?

# shutdown -Fm

23. How to log ftp accesses to a file

a. Add the below line in /etc/syslog.confdaemon.debug /tmp/daemon.log
b. # touch /tmp/daemon.log
c. # refresh syslogd
d. Modify your inetd.conf so that ftpd is called with the “-l” flag.

24. How to find a file name from inode number ?

# ncheck -i xxxx /mountpoint
where xxxx -> inode number of the file

25. How to redirect the system console to a file or tty temporarily

# swcons /tmp/console.out


# swcons /dev/tty5

26. How to recreate a deleted /dev/null file ?

# /bin/mknod /dev/null c 2 2

27. How to add commands that should get executed during every system shutdown ?

Add them to /etc/rc.shutdown

28. How to reduce the size or do cleanup of /var/adm/wtmp ?

# > /var/adm/wtmp

29. How to find out the fileset a file belongs to ?

# which_fileset command_name

30. In which file, the mapping of file Vs fileset stored ?

# /usr/lpp/bos/AIX_file_list

31. How to set maximum logins for a user in a system ?

Change the value of “maxlogins” under “usw” stanza in /etc/security/login.cfg

32. How to change the initial message that prints while logging in ?

Change the value of “herald” in /etc/security/login.cfg

33. How to set the # of seconds the user is given to enter their password ?

Change the value of “logintimeout” under “usw” stanza in /etc/security/login.cfg

EZH – Easy HMC Command Line Interface

EZH – Easy HMC Command Line Interface

EZH is a script for the IBM HMC console to provide an alternate, easier to use, command line interface for many common commands and the goal of the project is to make the HMC command line interface easier to use for day to day administration tasks.
Starting with version 0.6 it also has a interactive menu to make it even easier to use (“ezh” command)

See a video overview/demo of EZH at:

Boost Your Productivity with Single-Line AIX Shell Scripts


Boost Your Productivity with Single-Line AIX Shell Scripts

Learn how to create time-saving shell scripts for AIX, UNIX, or Linux that run on a single command line.

Click here to read more on the PowerITPro site


AIX 6.1 TL7 introduced a new flag for the ‘lspv’ command which shows the unique id (UUID) of disks in additional columns of the lspv output.

AIX 6.1 TL7 introduced a new flag for the ‘lspv’ command which shows
the unique id (UUID) of disks in additional columns of the lspv

This new ‘lspv -u’ is particularly useful in VIO environments using
VSCSI because the VIO client LPAR hdisk UDID contains the real UDID
from the VIO server hdisk.

For example on a client LPAR using VSCSI for the rootvg (merged
columns and spaces in the UDID are not a paste error):

Client LPAR # lspv -u
hdisk0          00000000fb8a0572                    rootvg          active      533E3E21360170E50202E5A5A0000025E50A12AB20F1746      FAStT03IBMfcp05VDASD03AIXvscsi8060a98a-0292-e2c9-0382-b5263f2a7e61

VIO1 # lspv -u
hdisk0          0000000017b33224                    rootvg          active              2A1135000C5005474B9C30BST9146853SS03IBMsas                          b98fed26-76da-f15c-45c9-b65a814e3d75
hdisk1          000000009c4ae1f9                    rootvg          active              2A1135000C500546FA9330BST9146853SS03IBMsas                          c3435ec2-3db2-6c0e-f14e-947243ba482d
hdisk2          000000000572fb8a                    None                                3E21360170E50202E5A5A0000025E50A12AB20F1746      FAStT03IBMfcp      a9be7b27-42fd-b0d6-a5ba-da61929cf4fc
hdisk3          0000000038963f05                    None                                3E21360170E50202E5A5A0000037350A526780F1746      FAStT03IBMfcp      7ed82295-3d9e-36dc-d6e9-e094d0d1a4ee

VIO2 # lspv -u
hdisk0          00000000b46edc87                    rootvg          active              2A1135000C5004CE6C7FF0BST9146853SS03IBMsas                          a36f5dae-8281-4df7-7fa7-e9fbf619c7d5
hdisk1          00000000605de1f9                    rootvg          active              2A1135000C5004CE6CF8F0BST9146853SS03IBMsas                          d1148dc8-ea98-a255-bf34-2921a56e8ca1
hdisk2          000000000572fb8a                    None                                3E21360170E50202E5A5A0000025E50A12AB20F1746      FAStT03IBMfcp      a9be7b27-42fd-b0d6-a5ba-da61929cf4fc
hdisk3          0000000038963f05                    None                                3E21360170E50202E5A5A0000037350A526780F1746      FAStT03IBMfcp      7ed82295-3d9e-36dc-d6e9-e094d0d1a4ee

Our client UDID contains the UDID from the VIO server with a prefix
and suffix:

client hdisk0: 533E3E21360170E50202E5A5A0000025E50A12AB20F1746      FAStT03IBMfcp05VDASD03AIXvscsi
vio1   hdisk2: ^^^^3E21360170E50202E5A5A0000025E50A12AB20F1746      FAStT03IBMfcp^^^^^^^^^^^^^^^^^

where ^ indicates the prefix and suffix added by the VIO server.

Using UDIDs the client can be cross referenced to the server quickly
with the most significant bytes of the UDID, in this case the middle
15 digits.

Historically to find the real LUN that a client is using in a VIO
environment would require the following steps for each VIO server:

– Obtain client hdisk parent vscsi device hardware location code and
LUN number
– Lookup on HMC which VIO server and slot the client vscsi device is
linked to
– Lookup vhost adapter on VIO server by slot number
– Lookup VSCSI mappings for vhost adapter to location hdisk on VIO server

A client with dual VIO would have to repeat the procedure twice. PVIDs
can also shortcut the process, but they may not show up on the VIO
server’s lspv output until after they are written to by the client and
the VIO server is rebooted. If the client rewrites the PVID, the VIO
server can also be out of date. Thus UDID’s are the preferred method
because they are static values.

The output can stretch the columns until they merge and spaces in the
UDID break the columns, which I hope is fixed in a future release.


Russell Adams                  

PGP Key ID:     0x1160DCB3 

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

HMC/SDMC/FSM Scanner Overview – downloads system configuration, produces single Excel spreadsheet, contains configuration of servers and LPARs

HMC Scanner Overview


HMC Scanner is a Java program that uses SSH to connect to an HMC or SDMC or FSM, downloads the system configuration and produces a single Excel spreadsheet that contains the configuration of servers and LPARs. The result is a simple way to document configuration and to easily look at most important configuration parameters. In PureFlex environments, only Power Systems compute nodes are detected.
Information is organized in tabs

System summary: name, serial number, cores, memory, service processor IP for each server

LPAR Summary: list of all LPAR by serve with status, environment, version, processor mode

LPAR CPU: processor configuration of each LPAR

LPAR MEM: memory configuration of each LPAR

Physical Slots: list of all slots of each system with LPAR assignment, description, physical location and drc_index

Virtual Ethernet: network configuration of each virtual switch and each LPAR

Virtual SCSI: configuration of all virtual SCSI adapters, both client and server

VSCSI Map: devices mapped by each VIOS to partitions

Virtual Fibre: virtual fibre channel configuration of client and server with identification of physical adapter assigned

SW Cores: LPAR and virtual processor pool configuration matrix to compute the number of software licenses. Simulation of alternative scenarios is possible.

CPU Pool Usage: easy to read history of CPU usage of each system. Based on last 12 months of lslparutil data.

Sys RAM Usage: easy to read history of physical memory assignement to each LPAR. Based on last 12 months of lslparutil data.

LPAR CPU Usage: easy to read history of CPU usage of each LPAR. Based on last 12 months of lslparutil data.


The tool is constantly updated to match changes in tool syntax, to manage new data types and to add new features. If you have any problem or any suggestion to improve HMC Scanner, please send me a mail ( Since new features are mostly suggested by users, propose yours! Please always include the downloaded files to allow be proper debugging.

HMC Scanner is packaged in a single ZIP file available in the download section of this page. A sample report is included.

This tool is not officially supported by IBM. No guarantee is given or implied, and you cannot obtain help from IBM. It a personal project of the author, Federico Vagnini (IBM Italy).

See also pGraph page form the same author.

The code exploits features from other software. See text file in the ZIP file for license details.

AIX Shell Scripting Made Easy

AIX Shell Scripting Made Easy

September 2012 | by Andrew Wojnarek

In “AIX Shell Scripting Made Simple,” I explained the basics of shell scripting and why it’s so useful. However, it’s not only simple, but easy! Delving further, we’ll see how easy and powerful this tool can be. Additionally, we’ll explore building more advanced borne shell scripts as well as perl “one-liners” for certain situations.

As you may know, IBM releases security vulnerability information for AIX. The site usually gives a description of the vulnerability, fileset levels it effects and where to find the PTF/EFIX. So the script, if built right, will go out to all your servers and detect whether they’re vulnerable.

The Shell Script

The mockup script shown here assumes you have keys set up to SSH out to each server. It does not have to be run as root. The entire shell script, without comments, can be found here.

#!/usr/bin/env sh
# Checks for vulnerability in AIX RPC first issued May 8th.     

# Variables #
# These are all the levels vulnerable to this exploit.
_vulnerable_levels=(  "" "" "" ""
 "" "" "" "" ""
 "" "" "" "" ""
 "" "" "" "" ""
 "" "" "" "" ""
 "" "" "" "" ""
 "" ""  "" "" ""
  ""  ""  ""  ""  ""
  ""  ""  ""  ""  ""
  ""  ""  ""  ""  ""
  "" "" "" "" )

This produces an array with the filesets affected by this vulnerability, which is important because we need to define all of the vulnerable filesets. You can find these values on the site where the vulnerability is defined.

_ssh_opts='-q -o BatchMode=yes -o ConnectTimeout=20
 -o ConnectionAttempts=1 -o ClearAllForwardings=yes'

This indicates the options we’re going to use to SSH to each servers. You can change these without affecting the script output.

# Makes text bold.
_b=`tput smso`

# Unset text bold.
_nb=`tput sgr0`

_date=`date +"%m%d%y_%H%M%S"`

_hosts="host1 host2 host3"

This variable specifies which servers you want to use. If you don’t set it, it won’t work.

for _host in ${_hosts}
        # Go out to the server and make sure it is AIX.
 If it's not, skip it.
        _uname=`ssh ${_ssh_opts} ${_host} "uname"`
        if [ "${_uname}" != "AIX" ]; then

        # Get the fileset level for
        _actual_host_level=`ssh ${_ssh_opts} ${_host} "lslpp -L | grep | awk '{ print \\$2 }'"`

The line above SSHs out to the server, ${_host}, and gets the value for the affected fileset—in this case

        # Failure counter.

        # Main loop.
        for _vulnerable_level in ${_vulnerable_levels[@]} #

(Notice the [@], which represents the entire array.)

                # If the values from our array match actuals, then say so.
                if [ "${_actual_host_level}" = "${_vulnerable_level}" ]; then
                        printf "${_host} is vulnerable with of 
${_actual_host_level}.\n"     | tee -a rpc.scan.${_date}
                        _fail=`expr ${_fail} + 1`

Here is the loop where we take the value of the fileset from our server and compare it to the filesets in our array.

        # If our failure counter hasn't gone off, then declare us not vulnerable.
        if [ ${_fail} -eq 0 ]; then
                printf "${_host} is not vulnerable.\n" | tee -a rpc.scan.${_date}

Perl One-Liners

Perl one-liners are extremely versatile tools. While probably not needed every day, they’re great to write down and keep handy, when needed. Having that perfect one-liner you need is often impressive to those around you. While, not critical, it’s kind of cool:

1. Convert Epoch (UNIX time; since January 1st 1970) to human readable time.

perl -e 'print scalar(localtime(EPOCHTIME)), "\n"'


[root@aix61-03]/root> perl -e 'print
 scalar(localtime(1342885345)), "\n"'
Sat Jul 21 11:42:25 2012

This one is very useful on AIX for determining the last time a user changed his or her password. To do so, look in the /etc/security/passwd file. It will look like this:

        password = encryptedpassword
        lastupdate = 1311019884

So take the lastupdate epoch time number, and place it inside the perl parentheses to get the last time the password was changed.

2. Remove all blank lines from a file.

perl -ne 'print unless /^$/' FILE


This is our test file:

[root@gvicaix61-03]/root> cat test
This is a line

This is a space ^

This is two spaces ^

This is using our one-liner:

[root@aix61-03]/root> perl -ne 'print unless /^$/' test
This is a line
This is a space ^
This is two spaces ^

3. Insert line numbers on a file.

perl -ne 'print "$. $_"' FILE


[root@aix61-03]/root> perl -ne 'print "$. $_"' test
1 This is a line
3 This is a space ^
6 This is two spaces ^

As we moved beyond the basics of shell scripting, creating arrays, comparing values and understanding more advanced logic are important lessons to learn. The perl one-liners are an excellent resource to keep in your back pocket as well. In my next shell scripting article, we’ll dive into more advanced borne scripting, and introduce other languages well-suited for sysadmin tasks.