IBM Developer

Tutorial

Streamline IBM AIX evolution- best practices to handle interim fix, pre- and post- migration tasks, and updates

Mastering nimadm and alt_disk_install commands for smooth AIX updates and migrations, including strategies to overcome challenges

By Srikanth Thanneeru, Emerson Lima

Introduction

Embarking on an IBM AIX migration or update journey can be both exciting and challenging. This tutorial comprehensively explains the process of updating or migrating AIX, while also detailing how to run user-defined scripts or applications before or after these operations. Let's learn the process by uninstalling and reinstalling interim fixes both before and after the migration, along with updating the operating system (OS) level. Additionally, we demonstrate dnf package manager as the application installation step post-migration or update of AIX. Whether you're a seasoned AIX administrator or just getting started, this guide aims to make the process clearer and more accessible.

Understanding the basics

Before we dive into the topic details, let's establish some key terms.

  • An interim fix is a swift code update delivered by AIX technical support to address specific known problems or authorized program analysis reports (APARs), while a formal program temporary fix (PTF) is in development.
  • AIX Network Installation Management (NIM) empowers you to manage the installation of the base operating system (BOS) and optional software on one or more systems.
  • NIMADM (Network Install Manager Alternate Disk Migration) is a powerful command that facilitates various tasks, including creating and migrating copies of root volume group (rootvg).
  • OS migration versus OS update Distinguishing between migration and update of an operating system is vital. An update operation facilitated by commands such as nim -o alt_disk_install is valid for transitions between maintenance or fix levels, affecting only the M or F fields of the Version number, release number, modification number, and fix pack number (V.R.M.F.). In contrast, a migration involves transitioning to a different AIX base level, such as moving from AIX 6.1 to AIX 7.1 or directly from AIX 5.3 to AIX 7.1 (bypassing two-stage updates).

Now with some of the basics in hand, let’s start our journey of understanding the process involved in AIX migration and AIX update along with the tips to overcome the challenges.

AIX migration

We recommend using the nimadm utility for AIX migrations due to its efficiency and minimal downtime. This utility allows for the creation of a duplicated rootvg for a NIM client on a spare disk, enabling seamless migration without disrupting the client.

Prerequisites

Make sure that the following prerequisites are fulfilled before proceeding with the migration process:

  • The NIM master must have the `alt_disk_install.rte’ fileset installed in the designated Shared Product Object Tree (SPOT) allocated for migration.
  • The NIM master must be at the same or a later AIX level compared to the selected lpp_source and SPOT resources designated for migration.
  • The NIM client is required to have a spare disk space that is sufficient for cloning the existing rootvg. Additionally, there should be extra free space available to accommodate potential file system expansion based on the configuration of the client.

Advantages of using nimadm utility for migration

Migration using the nimadm utility provides the following benefits:

  • Migration takes place while the NIM client is operational, minimizing disruptions to applications and services.
  • Downtime is restricted to a few minutes for a system restart.
  • In the event of migration failure, the original rootvg remains intact, minimizing the overall impact.
  • The nimadm utility demonstrates high flexibility, allowing for customization through NIM resources, including image_data, bosinst_data, and pre-migration and post-migration scripts.

Manage AIX migration using nimadm scripts

The nimadm command performs migration in 12 phases. Each phase can be run individually, using the -P flag. The nimadm phases must be run sequentially. For more information, refer to nimadm Command documentation on ibm.com.

To enhance control over the migration process, the nimadm utility facilitates both pre-migration and post-migration tasks through NIM scripts, with specific flags specifying script resources:

  • -a <PreMigrationScript>: Specifies the pre-migration NIM script resource.
  • -z <PostMigrationScript>: Specifies the post-migration NIM script resource.

The pre-migration script runs on the NIM master within the client's alt_inst environment before migration, while the post-migration script runs after migration completion.

Challenges of running post-migration scripts in AIX migration

The post-migration script operates on the NIM master within the environment of the client's alt_inst file system, mounted on the master using the chroot command. This setup imposes limitations on operations outside the chroot jail, restricting tasks such as expanding the client's alt_inst file system. If an operation demands additional space, such as expanding file systems during the process, it becomes unfeasible. For instance, downloading dnf requires more space in `/tmp’ and `/opt’. Therefore, it is advisable to run the nimadm utility until phase 6 and subsequently expand the required file system sizes before proceeding.

The following steps demonstrate the process of running the nimadm utility in phases, along with expanding the file system.

  1. Run the initial six phases of nimadm utility using the following command. nimadm -j VGname -l lpp_source -c NIMClient -s SPOT -d TargetDisks -a PreMigrationScript -b installp_bundle -Y -P 1,2,3,4,5,6
  2. Expand the file system using the following command. chfs -a size=+<size> /${NIM_CLIENT}_alt/alt_inst/<fs_name>
  3. Run the remaining phases of nimadm utility using the following command. nimadm -j VGname -l lpp_source -c NIMClient -s SPOT -d TargetDisks -z PostMigrationScript -b installp_bundle -Y -P 7,8,9,10,11,12

Sample custom script for AIX migration

The following sample script contains a series of instructions to remove the existing interim fixes and upgrade the dnf on an AIX system.

# Remove any existing interim fix profiles.
/tmp/remove_efix
#!/usr/bin/ksh
set -x
/usr/sbin/emgr -P | grep installp | awk "{print \$3}" | xargs -i emgr -r -L {}
# Set up the environmental variables of dnf.
/tmp/dnf_update.sh
#!/bin/ksh
set -x
export LANG=C
export LIBPATH=/opt/freeware/lib64
# Create a temporary directory.
/usr/bin/mkdir /tmp/cg
/usr/bin/echo "Return code is: $?"
# Change the working directory.
/usr/bin/cd /tmp/cg/
/usr/bin/echo "Return code is: $?"

/usr/bin/rm -f dnf_aixtoolbox.sh
# Download the dnf script using library for WWW in Perl (LWP).
export PERL_LWP_SSL_VERIFY_HOSTNAME=0
/usr/opt/perl5/bin/lwp-download https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/dnf_aixtoolbox.sh
/usr/bin/echo "Return code is: $?"
# Set permissions for the downloaded script.
/usr/bin/chmod 777 ./dnf_aixtoolbox.sh
/usr/bin/echo "Return code is: $?"
# Install dnf using the downloaded script.
./dnf_aixtoolbox.sh -y
/usr/bin/echo "Return code is: $?"
# Verify installation and list installed packages.
/usr/bin/echo "#### Check for /usr/sbin/updtvpkg.... #######"
/usr/sbin/updtvpkg
/usr/bin/echo "Return code is: $?"

/usr/bin/echo "#### Run rpm -qa....####"
/usr/bin/rpm -qa
# Update dnf.
/usr/bin/echo "Running dnf update....###"
/opt/freeware/bin/dnf update -y
/usr/bin/echo "Return code is: $?"

AIX update

Initiate the AIX update by cloning rootvg using the nim -o alt_disk_install command as shown.

nim -o alt_disk_install -a source=rootvg -a disk=target_disk(s) -a attribute=Value... TargetName | TargetNames

The alt_disk_install command can be run in three distinct phases:

  • Phase 1: This phase involves establishing the altinst_rootvg volume group, alt_logical volumes, /alt_inst file systems, and reinstating the mksysb or rootvg data.
  • Phase 2: During this phase, updates, new file sets, fixes, or bundles (cloning only) are installed. Additionally, any specified customization script is run, a resolv.conf file is copied if specified, and files are replicated to maintain NIM client status if required.
  • Phase 3: In this final phase, the /alt_inst file systems are dismounted, file system and logical volume names are modified, alt_logical volumes are eliminated, Object Data Manager (ODM) is designated, altinst_rootvg is deactivated, and the bootlist is set. If specified, the system is rebooted.

Although a script parameter can be specified to run after updating new filesets, performing operations before updating new file sets is not feasible with this approach.

To overcome this limitation, run the alt_disk_install command in the following manner:

  • Initiate phase 1 of the alt_disk_install operation using nim -o alt_disk_install <phase 1> command.
  • Define a pre-update script and invoke it from the nim master on the client.
  • Run nim -o alt_disk_install <phase 2> command to proceed with installing update files, installing interim fix, and starting the post-update script.

This approach ensures that all desired operations are carried out prior to the update_all of the packages during phase 2 of the alt_disk_install command. The script is triggered on the operating system currently running on the client and not from the environment of the client's alt_inst file system. To accomplish this, the syntax chroot <client_env> “<command>” can be utilized.

Run the following command to remove an interim fix within the client's alt_inst environment.

/usr/sbin/chroot /alt_inst "emgr -P | grep installp | awk '{print $3}' | xargs -i emgr -r -L {}”

This command operates within the specified alt_inst environment, ensuring the removal of the specified interim fix.

Update AIX and install dnf

The following steps demonstrate the process of AIX update with dnf installation on an alternate disk using the nim command and custom scripts.

  1. Clone AIX system with alternate disk. nim -o alt_disk_install -a source=rootvg -a disk=hdisk1 -a phase=1 idevp8-lp5

  2. Remove existing interim fixes before update Technology Level (TL).

    nim -o define -t script -a server=master -a location=/tmp/rem_efix.sh rem_efix
    nim -o cust -a script=rem_efix idevp8-lp5
    
  3. Remove existing interim fixes before update Technology Level (TL).

    nim -o define -t script -a server=master -a location=/tmp/rem_efix.sh rem_efix
    nim -o cust -a script=rem_efix idevp8-lp5
    
  4. Update AIX TL.

    nim -o alt_disk_install -a source=rootvg -a disk=hdisk1 -a lpp_source=2404A_72Z_LPP -a phase=2 -a filesets=update_all -a installp_flags=acngXY idevp8-lp5
    
  5. Install new interim fixes.

    nim -o alt_disk_install -a source=rootvg -a disk=hdisk1 -a lpp_source=2404A_72Z_LPP -a phase=2 -a installp_bundle=ifix -a installp_flags=acngXY idevp8-lp5
    
  6. Install and update dnf package manager. nim -o cust -a script=dnf_update idevp8-lp5

  7. Unmount the alternate disk.

    nim -o alt_disk_install -a source=rootvg -a disk=hdisk1 -a lpp_source=2404A_72Z_LPP -a phase=3 -a filesets=update_all -a installp_flags=acngXY idevp8-lp5

Sample custom script for AIX update

Following is a custom script that can be used to automate the AIX TL update process on an alternate disk, including the installation of the dnf package manager.

# Remove existing interim fixes.
/tmp/rem_efix.sh
#!/usr/bin/ksh
set -x
labels=`usr/sbin/chroot /alt_inst /usr/sbin/emgr -l | awk '/^[0-9]+/ {print $3}'`

# Check if labels are not empty.
if [ -n "$labels" ]; then
    # Iterate through the labels
    for label in $labels; do
        # Run emgr -r -L with each label
        /usr/sbin/chroot /alt_inst /usr/sbin/emgr -r -L "$label"
    done
else
    echo "Error: Unable to extract labels from emgr -l output."
fi

# Set up the environmental variables of dnf.
/tmp/dnf_update.sh
#!/bin/ksh
set -x
export LANG=C

# Create a temporary directory.
/usr/bin/rm -rf /tmp/cg
/usr/bin/mkdir /tmp/cg
/usr/bin/echo "Return code is: $?"

# Change the working directory.
/usr/bin/cd /tmp/cg/
/usr/bin/echo "Return code is: $?"

/usr/bin/rm -f dnf_aixtoolbox.sh

# Download the dnf script using Perl LWP.
export PERL_LWP_SSL_VERIFY_HOSTNAME=0
/usr/opt/perl5/bin/lwp-download https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/dnf_aixtoolbox.sh
/usr/bin/echo "Return code is: $?"

# Set permissions for the downloaded script.
/usr/bin/chmod 777 ./dnf_aixtoolbox.sh
/usr/bin/echo "Return code is: $?"

/usr/bin/cp ./dnf_aixtoolbox.sh /alt_inst/

# Install dnf using the downloaded script.
chroot /alt_inst ./dnf_aixtoolbox.sh -y
/usr/bin/echo "Return code is: $?"

# Verify installation and list installed packages.
/usr/bin/echo "#### Check for /usr/sbin/updtvpkg.... #######"
chroot /alt_inst /usr/sbin/updtvpkg
/usr/bin/echo "Return code is: $?"

/usr/bin/echo "#### Run rpm -qa....####"
/usr/bin/rpm -qa,

# Update dnf.
/usr/bin/echo "Running dnf update....###"
/usr/bin/echo "Return code is: $?"
chroot /alt_inst /opt/freeware/bin/dnf update -y
/usr/bin/echo "Return code is: $?"

Summary

AIX evolution is a journey that demands meticulous planning and implementation. In this tutorial we have explored the intricacies of updating and migrating AIX, delving into the challenges that may arise, and providing expert tips to overcome them. Armed with these pro tips and a clear understanding of AIX terminology, you’ll be able to navigate the complexities with confidence.