Pages

Running IBM AIX 7.2 on x86 with QEMU POWER8 Emulation – Lab Setup Guide

This document describes the procedure to deploy IBM AIX 7.2 TL04 SP02 (7200-04-02) using QEMU POWER8 emulation on an Ubuntu Server virtual machine running inside VMware Workstation.

This environment enables administrators and engineers to build a functional AIX lab environment on x86 hardware without requiring IBM Power Systems.

The lab environment can be used for:
  • AIX system administration practice
  • Software testing and compatibility validation
  • Networking and storage configuration experiments
  • OpenSSH configuration and security testing
  • Development and educational purposes
Since the host platform is x86, QEMU uses TCG (Tiny Code Generator) for software emulation of the POWER architecture.

2. Prerequisites
2.1 Hardware Requirements
Component                       Requirement
CPU Intel                      VT-x/EPT or AMD-V/RVI
RAM Minimum                    16 GB recommended
Storage                            Minimum 60 GB free space
Hypervisor                    VMware Workstation Pro or Player

Important Notes
VT-x / AMD-V is required for Ubuntu VM performance, not for POWER acceleration.
AIX will run using QEMU TCG software emulation.

3. Create Ubuntu Server Virtual Machine
3.1 Create VM in VMware Workstation
Open VMware Workstation
Select Create New Virtual Machine
Configuration:
Setting                                                     Value
Guest OS                       Linux
Version                             Ubuntu 64-bit
ISO Image                       ubuntu-24.04.4-live-server-amd64.iso
Memory                              8–16 GB
CPU Minimum                      4 cores
Disk                              100 GB recommended
Network                             Bridged (recommended) or NAT

3.2 Enable CPU Virtualization
Navigate to:
VM → Settings → Processors
Enable:
Virtualize Intel VT-x/EPT or AMD-V/RVI
Virtualize CPU performance counters (optional)
Ensure hardware virtualization is enabled in system BIOS.

4. Install Ubuntu Server
Download Ubuntu Server ISO:
https://ubuntu.com/download/server
File:
ubuntu-24.04.4-live-server-amd64.iso
Installation Steps
4.1 Boot VM using the ISO.
4.2 Select:
Try or Install Ubuntu Server
4.3 Installation sequence:
  • Language → English
  • Ubuntu Server Installation
  • Configure Network
  • Configure Storage (LVM recommended)
  • Create User ID and Password
  • Enable OpenSSH Server
  • Start Installation
After installation completes, log in and update the system.
System Update :
$ sudo apt update
$ sudo apt upgrade -y

5. Install QEMU for POWER Architecture
Install QEMU packages required for POWER emulation.
$ sudo apt update
$ sudo apt install qemu-system-ppc qemu-utils
Verify Installation
# qemu-system-ppc64 --version
Example output:
QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.12)
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers

6. Configure Br0 & Br1 for AIX VM to connect Private Network
# vi 
/etc/netplan/50-cloud-init.yaml
Example:
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: no
    ens192:
      dhcp4: no
  bridges:
    br0:
      interfaces: [ens160]
      addresses: [192.168.10.108/24]
      gateway4: 192.168.10.1
      nameservers:
        addresses: [192.168.10.100]
        search: [ppc.com]
      parameters:
        stp: false
        forward-delay: 0
    br1:
      interfaces: [ens192]
      addresses: [192.168.20.108/24]
      gateway4: 192.168.20.1
      nameservers:
        addresses: [192.168.20.100]
        search: [ppc.com]
      parameters:
        stp: false
        forward-delay: 0

Note: If you are using VMware ESXI then make sure below setting need to be enable security level:


7. AIX Disk Template Preparation
Install the AIX 7.2 TL04 SP02 server.
adminCtrlX – Simplifying System Administration: Install QEMU PPC64 on Ubuntu 24.04.4 & Deploy IBM AIX 7.2 TL04 SP02

After Installation AIX 7200-04-02 then Setup .profile 
# vi .profile
Example:
indaixwpr01 / # cat .profile
# Root Profile
export HOST=$(uname -n)
# Terminal & Input
export TERM=vt100
stty erase ^H
stty erase ^?
# Path & Libraries
export PATH=/usr/bin:/usr/sbin:/etc:/usr/local/bin:/usr/bin/X11:$HOME/bin:.
export LIBPATH=/usr/lib:/lib:/usr/local/lib
# Shell Behavior
export PS1="$HOST \$PWD # "
export HISTSIZE=5000
export TMOUT=1800      # 30 minute timeout
export EDITOR=vi
export FCEDIT=vi
# System Limits
ulimit -f unlimited
ulimit -d unlimited
# Localization
export LANG=en_US
export LC_ALL=en_US
indaixwpr01 / #

Error:
error: db4 error(22) from dbenv->open: A system call received a parameter that is not valid.
error: cannot open Packages index using db4 - A system call received a parameter that is not valid. (22)
error: cannot open Packages database in /opt/freeware/packages
error: db4 error(22) from dbenv->open: A system call received a parameter that is not valid.
error: cannot open Packages index using db4 - A system call received a parameter that is not valid. (22)
error: cannot open Packages database in /opt/freeware/packages

To fix:
# rm /var/lib/rpm/__db*
# rpm --rebuilddb

Install sudo rpm package 
# rpm -Uvh sudo-1.9.17-3.aix71.rpm

smitty tcpip --->  Minimum Configuration & Startup

indaixwpr01 / # ifconfig -a
en0: flags=e084863,14c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 192.168.20.13 netmask 0xffffff00 broadcast 192.168.20.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
en1: flags=e084863,14c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 192.168.10.13 netmask 0xffffff00 broadcast 192.168.10.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1%1/64
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
indaixwpr01 / #

Shutdown AIX VM:
# shutdown -h

Destination directory:
/aix/image
Example template file: which is the part of the AIX installation boot disk:
aix_7200-04.qcow2

8. Disk Preparation Script
Create the script:
# vi prepare-disks.sh
Purpose:
  • Convert the AIX disk to template disk to RAW format
  • Create additional data disks for each VM
Script
------------------------------------------------------------------------------------------------------------------
#!/usr/bin/env bash
set -euo pipefail

BASE_IMG="/aix/image/aix_7200-04.qcow2"
DISK_DIR="/aix/disk"

if [ $# -lt 1 ]; then
    echo "Usage: $0 vmname1 [vmname2 vmname3 ...]"
    exit 1
fi

echo "Preparing disks for: $@"
echo

for SERVER in "$@"; do

    BOOT_DISK="${DISK_DIR}/${SERVER}-hdisk1.raw"
    DATA1_DISK="${DISK_DIR}/${SERVER}-hdisk2.raw"
    DATA2_DISK="${DISK_DIR}/${SERVER}-hdisk3.raw"

    echo "---- $SERVER ----"

    if [ ! -f "$BOOT_DISK" ]; then
        echo "Creating boot disk..."
        qemu-img convert -p -f qcow2 -O raw "$BASE_IMG" "$BOOT_DISK"
    fi

    if [ ! -f "$DATA1_DISK" ]; then
        echo "Creating hdisk2 (30GB)"
        qemu-img create -f raw "$DATA1_DISK" 30G
    fi

    if [ ! -f "$DATA2_DISK" ]; then
        echo "Creating hdisk3 (40GB)"
        qemu-img create -f raw "$DATA2_DISK" 40G
    fi

done

echo "Disk preparation completed."
------------------------------------------------------------------------------------------------------------------
8.1 Run Disk Preparation
Example:
# ./prepare-disks.sh indaixwpr01

Example output:
/aix/disk/indaixwpr01-hdisk1.raw
/aix/disk/indaixwpr01-hdisk2.raw
/aix/disk/indaixwpr01-hdisk3.raw

Verify disks:
ls -lh /aix/disk
Example:
-rw-r--r-- indaixwpr01-hdisk1.raw 30G
-rw-r--r-- indaixwpr01-hdisk2.raw 30G
-rw-r--r-- indaixwpr01-hdisk3.raw 40G

9. Start AIX Virtual Machine
This script:
  • Creates TAP network interfaces
  • Assigns bridge interfaces
  • Allocates memory and CPU
  • Starts QEMU POWER8 virtual machine
  • Exposes console via Telnet port
VM console ports will be allocated between:
8001 – 8100

Example command:
# ./start-vm.sh indaixwpr01
=================================
Starting VM: indaixwpr01
TAP0 (br0): tap0
TAP1 (br1): tap1
Telnet port: 8001
=================================
All requested VMs started successfully.

Create script:
# vi start-vm.sh
------------------------------------------------------------------------------------------------------------------
#!/usr/bin/env bash
set -euo pipefail

DISK_DIR="/aix/disk"
BRIDGE0="br0"
BRIDGE1="br1"
MEM="4G"          # Consider increasing to 8G for better performance
CPU="2"           # Can increase to match host cores
BASE_PORT=8001
LOG_DIR="/tmp"

if [ $# -lt 1 ]; then
    echo "Usage: $0 vmname1 [vmname2 vmname3 ...]"
    exit 1
fi

# ---------------- Functions -------------------

is_port_free() {
    local port=$1
    if ! lsof -i :${port} >/dev/null 2>&1; then
        if ! netstat -tln 2>/dev/null | grep -q ":${port} "; then
            return 0
        fi
    fi
    return 1
}

get_free_port() {
    local port=${BASE_PORT}
    while [ $port -le 8100 ]; do
        if is_port_free $port; then
            echo $port
            return 0
        fi
        port=$((port + 1))
    done
    echo "ERROR: No free ports available (8001-8100)" >&2
    exit 1
}

get_free_tap() {
    local index=0
    while [ $index -lt 200 ]; do
        local tap_name="tap${index}"

        if ! ip link show "${tap_name}" >/dev/null 2>&1; then
            ip tuntap add mode tap "${tap_name}" user "$(whoami)"
            ip link set "${tap_name}" up
            echo "${tap_name}"
            return 0
        fi

        index=$((index + 1))
    done

    echo "ERROR: No free TAP interfaces found (tap0-tap199)" >&2
    exit 1
}

generate_mac() {
    printf '52:54:00:%02X:%02X:%02X' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))
}

# ---------------- MAIN LOOP -------------------

for SERVER in "$@"; do

    if [ -f "${LOG_DIR}/${SERVER}.pid" ]; then
        OLD_PID=$(cat "${LOG_DIR}/${SERVER}.pid")
        if ps -p "${OLD_PID}" >/dev/null 2>&1; then
            echo "Stopping existing VM ${SERVER} (PID ${OLD_PID})"
            kill -9 "${OLD_PID}" || true
            sleep 1
        fi
        rm -f "${LOG_DIR}/${SERVER}.pid"
    fi

    TELNET_PORT=$(get_free_port)
    TAP0=$(get_free_tap)
    TAP1=$(get_free_tap)

    MAC0=$(generate_mac)
    MAC1=$(generate_mac)

    # ---- RAW disks ----
    BOOT_DISK="${DISK_DIR}/${SERVER}-hdisk1.raw"
    DATA1_DISK="${DISK_DIR}/${SERVER}-hdisk2.raw"
    DATA2_DISK="${DISK_DIR}/${SERVER}-hdisk3.raw"

    if [ ! -f "$BOOT_DISK" ]; then
        echo "Boot disk not found for ${SERVER}"
        echo "Run prepare-disks.sh first."
        exit 1
    fi

    echo "================================="
    echo "Starting VM: $SERVER"
    echo "TAP0 (br0): $TAP0"
    echo "TAP1 (br1): $TAP1"
    echo "Telnet port: $TELNET_PORT"
    echo "================================="

    ip link set "${TAP0}" master "${BRIDGE0}"
    ip link set "${TAP1}" master "${BRIDGE1}"

    UUID=$(uuidgen)

    nohup qemu-system-ppc64 \
      -name "${SERVER}" \
      -cpu POWER8 \
      -uuid "${UUID}" \
      -machine pseries,ic-mode=xics,memory-backend=ram0,cap-cfpc=broken,cap-ibs=broken,cap-ccf-assist=off,cap-sbbc=broken \
      -accel tcg,thread=multi,tb-size=4096 \
      -object memory-backend-ram,id=ram0,size=${MEM},prealloc=yes \
      -m ${MEM} \
      -smp ${CPU},cores=${CPU},threads=1,sockets=1 \
      -serial "telnet:127.0.0.1:${TELNET_PORT},server,nowait" \
      -display none \
      -device virtio-scsi-pci,id=scsi0 \
      -drive file="${BOOT_DISK}",if=none,id=drive-boot,format=raw,cache=writeback,aio=threads \
      -device scsi-hd,drive=drive-boot,bus=scsi0.0,scsi-id=0,bootindex=0 \
      -drive file="${DATA1_DISK}",if=none,id=drive-data1,format=raw,cache=writeback,aio=threads \
      -device scsi-hd,drive=drive-data1,bus=scsi0.0,scsi-id=1 \
      -drive file="${DATA2_DISK}",if=none,id=drive-data2,format=raw,cache=writeback,aio=threads \
      -device scsi-hd,drive=drive-data2,bus=scsi0.0,scsi-id=2 \
      -netdev tap,id=net${SERVER}0,ifname=${TAP0},script=no,downscript=no \
      -device spapr-vlan,netdev=net${SERVER}0,mac=${MAC0} \
      -netdev tap,id=net${SERVER}1,ifname=${TAP1},script=no,downscript=no \
      -device spapr-vlan,netdev=net${SERVER}1,mac=${MAC1} \
      -prom-env boot-command="boot disk:" \
      -prom-env input-device=vty \
      -prom-env output-device=vty \
      -prom-env term-type=vt100 \
      -prom-env use-nvramrc?=true \
      > "${LOG_DIR}/${SERVER}.log" 2>&1 &

    PID=$!
    echo "${PID}" > "${LOG_DIR}/${SERVER}.pid"
    sleep 1
done
echo "All requested VMs started successfully."

------------------------------------------------------------------------------------------------------------------

10. Verify Running VM
Check QEMU process:
# ps -ef | grep ppc
Example:
qemu-system-ppc64 -name indaixwpr01

11. Access AIX Console
Connect to VM console using Telnet.
Example:
telnet localhost 8001
This connects to the AIX system console.

12. Stop AIX Virtual Machine
Purpose:
Stop QEMU process
Remove TAP interfaces
Clean PID and log files
Example usage:
# ./stop-vm.sh indaixwpr01
Create script:
# vi stop-vm.sh
------------------------------------------------------------------------------------------------------------------
#!/usr/bin/env bash
set -euo pipefail

LOG_DIR="/tmp"

if [ $# -lt 1 ]; then
    echo "Usage: $0 vmname1 [vmname2 vmname3 ...]"
    exit 1
fi

for SERVER in "$@"; do
    PID_FILE="${LOG_DIR}/${SERVER}.pid"
    LOG_FILE="${LOG_DIR}/${SERVER}.log"

    echo "================================="
    echo "Stopping VM: $SERVER"
    echo "================================="

    # 1. Kill QEMU process
    if [ -f "$PID_FILE" ]; then
        PID=$(cat "$PID_FILE")
        if kill -0 "$PID" 2>/dev/null; then
            echo "Killing PID $PID (SIGTERM)..."
            kill "$PID"
            sleep 3
            if kill -0 "$PID" 2>/dev/null; then
                echo "Force kill PID $PID (SIGKILL)..."
                kill -9 "$PID"
            fi
        fi
        rm -f "$PID_FILE"
    fi

    # Fallback kill by name
    pkill -f "qemu-system-ppc64.*-name ${SERVER}" 2>/dev/null || true
    sleep 2

    # 2. **FIND EXACT TAP used by this VM from LOG FILE** (MOST RELIABLE)
    VM_TAP=""
    if [ -f "$LOG_FILE" ]; then
        VM_TAP=$(grep -o "TAP: tap[0-9]*" "$LOG_FILE" 2>/dev/null | tail -1 | cut -d' ' -f2 || true)
    fi

    # 3. **FIND TAP from /proc filesystem** (if log missing)
    if [ -z "$VM_TAP" ]; then
        VM_TAP=$(pgrep -f "${SERVER}" || true | \
                 xargs -r cat /proc/*/cmdline 2>/dev/null | \
                 grep -o "ifname=tap[0-9]*" | cut -d= -f2 | head -1 || true)
    fi

    # 4. **Delete ONLY this specific TAP**
    if [ -n "$VM_TAP" ] && ip link show "$VM_TAP" >/dev/null 2>&1; then
        echo "Deleting VM's TAP interface: $VM_TAP"
        ip link set "$VM_TAP" down 2>/dev/null || true
        sleep 0.5
        ip link delete "$VM_TAP" 2>/dev/null || true

        # Verify deletion
        if ! ip link show "$VM_TAP" >/dev/null 2>&1; then
            echo "TAP $VM_TAP deleted successfully"
        else
            echo "TAP $VM_TAP still exists"
        fi
    else
        echo "No TAP interface found for $SERVER"
    fi

    # Final verification
    if ! pgrep -f "qemu-system-ppc64.*-name ${SERVER}" >/dev/null 2>&1; then
        echo "VM $SERVER fully stopped....................................."
    else
        echo "VM $SERVER still running....................................."
    fi
    echo "Log: $LOG_FILE"
    echo ""
done
echo "Stop completed."
------------------------------------------------------------------------------------------------------------------

13. Manual TAP Interface Cleanup
If TAP interfaces remain after VM shutdown, remove them manually.
Example:
for i in tap0 tap1 tap2 tap3
do
sudo ip link delete $i
done

14. Log Files
VM logs and PID files are stored in:
/tmp

Example files:
/tmp/indaixwpr01.log
/tmp/indaixwpr01.pid

15. Performance Recommendations
Parameter            Recommended Value
Memory                 8 GB
CPU                    4 cores
Disk format          RAW
Networking          Bridged

Running multiple AIX VMs requires additional system memory.

Conclusion:
Using QEMU POWER8 emulation on Ubuntu Server, it is possible to deploy and operate IBM AIX 7.2 environments on x86 hardware.
This setup provides a flexible platform for:
  • AIX system administration practice
  • Software development and testing
  • Training and laboratory environments
Although performance is limited due to software emulation, it provides a reliable environment for functional testing and learning purposes.


No comments:

Post a Comment