How-To: Configure UCS for Hot-Adding CPU and Memory

Howto Configure UCS for Hot-Adding CPU And Memory

You want to be able to hot-add cpu and memory to your UCS virtual machine.

Step 1

Allow hot-adding of cpu and memory on your hypervisor.
This depends on your hypervisor. For UVMM this hot-adding cpu or memory not configurable at all. For VMware this can be enabled in the properties for cpu and memory of the VM but note the VM has to be powered off to enable hot-adding features.

Step 2

Once enabled you can hot-add cpu or memory in your hypervisor’s configuration tools. Again, depends on your hypervisor how to do it.

Step 3

Make sure your UCS operating system recognizes your added resources. By default UCS does not activate the hot-added resources.

Option 1 - Activating manually

Run the following script as root:

#!/bin/bash
# Based on script by William Lam - http://engineering.ucsb.edu/~duonglt/vmware/

# Bring CPUs online
for CPU in $(ls /sys/devices/system/cpu/ |grep -E '(cpu[0-9])')
do
        CPU_DIR="/sys/devices/system/cpu/${CPU}"
        echo "Found cpu: \"${CPU_DIR}\" ..."
        CPU_STATE_FILE="${CPU_DIR}/online"
        if [ -f "${CPU_STATE_FILE}" ]; then
                STATE=$(cat "${CPU_STATE_FILE}" | grep 1)
                if [ "${STATE}" == "1" ]; then
                        echo -e "\t${CPU} already online"
                else
                         echo -e "\t${CPU} is new cpu, onlining cpu ..."
                         echo 1 > "${CPU_STATE_FILE}"
                fi
        else 
                echo -e "\t${CPU} already configured prior to hot-add"
        fi
done

# Bring all new Memory online
for RAM in $(grep line /sys/devices/system/memory/*/state)
do
        echo "Found ram: ${RAM} ..."
        if [[ "${RAM}" == *":offline" ]]; then
                echo "Bringing online"
                echo $RAM | sed "s/:offline$//"|sed "s/^/echo online > /"|source /dev/stdin
        else
                echo "Already online"
        fi
done

Option 2 - Activating automatically

You can configure UCS to activate added resource automatically.
Create a file named “94-hotplug-cpu-mem.rules” in the folder /etc/udev/rules.d with the following content:

ACTION=="add", SUBSYSTEM=="cpu", ATTR{online}=="0", ATTR{online}="1"

ACTION=="add", SUBSYSTEM=="memory", ATTR{state}=="offline", ATTR{state}="online"

Then reboot your VM. After reboot all hot-added cpus or memory will automatically detected and activated.

Mastodon