The Power of the HMC Command Line

Edit: Some links no longer work.

Originally posted October 22, 2013 on AIXchange

When using the HMC, do you do more with the GUI or on the command line? The more systems you’re managing and the more operations you’re doing, the more you’ll benefit by getting comfortable with the HMC command line.

While I like new commands such as lsnportlogin and chnportlogin, the HMC command line itself isn’t new. For instance, this article from 2008 has some handy tricks. And to give you an idea of the wealth of useful information here, I’ll include the list of contents:

            HMC Management

                HMC Version

                Network configuration of the HMC

                Reboot the HMC

                How to change the HMC password (of user hscroot)

                Show Available Filesystem Space

            LPAR Management: Status Information

                LPAR Status

                Show Status and LED/LCD Display of an LPAR

                Show Status and LED/LCD Display of a Systems Running in FullPartitionMode

                Overview LPAR IDs

                Overview Connection State

                Show a List of all I/O Adapters

                Overview DLPAR status

            LPAR Management: Operations

                Soft Reset of an LPAR

                Soft Reset of a Systems Running in FullPartitionMode

                Hard Reset of an LPAR

                Hard Reset of a Systems Running in FullPartitionMode

                Virtual Console

                Activation of an LPAR

                How to boot an LPAR into SMS Menu

                How to Power on a System Running in FullPartitionMode

                Bring the key switch to position NORMAL

            LPAR Configuation

                Change an LPAR’s Name

                Rename a Managed System

                DLPAR: Increase the Number of Processing Units of an LPAR

            Operations in an virtualized environment

                Make virtual WWPNs visible to the SAN

                Show all virtual WWPNs assigned to an LPAR

                Logout virtual WWPNs from the SAN

Here are just a few things you can do from the HMC command line:

* Would you like to see all of the managed systems that are connected to your HMC? Run:

            lssyscfg -r sys -F name

* Perhaps you need to know which LPARs are on your machine and whether or not they’re running:

            lssyscfg -m Server1 -r lpar -F name:state

* This handy command lists every machine connected to your HMC, and tells you whether or not the LPARs on these devices are running:

            for m in $(lssyscfg -r sys -F name); do echo $m ; lssyscfg -r lpar -m $m -F name:state ; done

* Maybe you want to know the machine name, along with the IP address the service processor is using, and whether or not it’s connected to the HMC:

            lssysconn -r all -F type_model_serial_num:ipaddr:state | sort

* Maybe you want to see which I/O devices are assigned to which LPARs:

            lshwres -r io -m Server1 –rsubtype slot -F lpar_name:drc_name:description

* Or perhaps you want to see the profile information for your LPAR 1:

            lssyscfg -r prof -m Server1 –filter “lpar_ids=1”

* Another command I like is lssyscfg, which helps you determine all of the wwpns associated with your LPAR:

            lssyscfg -r prof -m Server1 -F virtual_fc_adapters –filter lpar_names=lpar1

This command would provide this output:

“””2405/client/3/vios2/2405/c0507606b5ef0012,c0507606b5ef0013/0″”,””1605/client/2/vios1/1605/c0507606b5ef0010,c0507606b5ef0011/0″”,””2605/client/3/vios2/2605/c0507606b5ef0014,c0507606b5ef0015/0″”,””1405/client/2/vios1/1405/c0507606b5ef0016,c0507606b5ef0017/0″””

* With this command, you can easily see what the adapter numbers are and which VIO server they’re connected to. Obviously you could change what you’re filtering on; in this case we’re just looking it up via LPAR ID number rather than the LPAR NAME:

            lssyscfg -r prof -m Server1 -F virtual_fc_adapters –filter lpar_ids=8

* Maybe you want to list every WWPN for every LPAR on your machine with its default profile:

            lsnportlogin -m Server1 –filter “profile_names=default”

* Or maybe you really just want the WWPNs without other information included:

            lsnportlogin -m Server1 –filter lpar_names=lpar1 | cut -c 68-88

wwpn=c0507602c5340034

            wwpn=c0507602c5340035

            wwpn=c0507602c5340042

            wwpn=c0507602c5340043

            wwpn=c0507602c5340044

            wwpn=c0507602c5340045

            wwpn=c0507602c5340030

            wwpn=c0507602c5340031

* Maybe you want to list out the LPAR names with the WWPNs:

            lssyscfg -r prof -m Server1 –filter lpar_names=lpar1 -F lpar_name,virtual_fc_adapters

* Or you could check every frame connected to your HMC with something like this:

            lssyscfg -r sys -F name |
            while read M; do lshwres -r virtualio –rsubtype fc –level lpar -m $M -F lpar_name,wwpns|
            sed ‘s/^/’$M,’/’
            done

* This loop is used to login the virtual fibre adapters of all of the LPARs on a frame:

            for i in `lssyscfg -m Server1 -r lpar -F name`; do echo $i;chnportlogin -o login -m Server1 -p $i ; done

There’s much more of course, but this should give you an idea of the power of the HMC command line.

Finally, some interesting links this week courtesy of those I follow on Twitter:

@cgibbo Dynamic Platform Optimizer with Tracy Smith. October 31, 2013. Register now. https://www1.gotomeeting.com/register/214938672 … https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power+Systems/page/AIX+Virtual+User+Group+-+USA … #AIX

RT @UnixToolTip RT @jpmens: Unix Recovery Legend http://www.ee.ryerson.ca/~elf/hack/recovery  …

@mr_nmon IDC Whitepaper on security of #PowerVM Virtualisation http://public.dhe.ibm.com/common/ssi/ecm/en/pol03175usen/POL03175USEN.PDF … Double standards: POWER=mission critical & x86 anything goes!

@ibmperformance Oracle’s hardware business may be worse than we thought http://gigaom.com/2013/10/14/oracles-hardware-business-may-be-worse-than-we-thought/ … via @gigaom

@chromeaix #powersystems #AIX Using the NIM service handler with the NIM Alternate Disk Migration tool http://ow.ly/2ADpjg