We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Hot Add Scripte


Stefan
06.09.11, 01:35
Hier 3 Scripte, dass Ram, Cpu und Speicherplatz der VMs erweitert werden und ohne Reboot direkt aktiv sind.(Scripte in der VM starten)

Memory

#!/bin/bash

for MEMORY in $(ls /sys/devices/system/memory/ | grep memory)
do
SPARSEMEM_DIR="/sys/devices/system/memory/${MEMORY}"
echo "Found sparsemem: \"${SPARSEMEM_DIR}\" ..."
SPARSEMEM_STATE_FILE="${SPARSEMEM_DIR}/state"
STATE=$(cat "${SPARSEMEM_STATE_FILE}" | grep -i online)
if [ "${STATE}" == "online" ]; then
echo -e "\t${MEMORY} already online"
else
echo -e "\t${MEMORY} is new memory, onlining memory
..."
echo online> "${SPARSEMEM_STATE_FILE}"
fi
done



CPU

#!/bin/bash

for CPU in $(ls /sys/devices/system/cpu/ | grep cpu | grep -v idle)
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



Disk :

test1:~# cat online_hotplug_disk.sh
#!/bin/bash

echo "- - -"> /sys/class/scsi_host/host0/scan
#echo "scsi scan-new-devices"> /proc/scsi/scsi