Adding RAM and CPU

It is possible to hot-add RAM and CPU (useful in virtual environment) without rebooting the machine.

The following commands can be used.

For the RAM (as root):

for i in $(grep -l offline /sys/devices/system/memory/*/state); do echo online > $i; done

For the CPU (as root):

for i in $(grep -l 0 /sys/devices/system/cpu/*/online); do echo 1 > $i; done

If the RAM or CPU amounts are reduced, it is of course advised to do it after shutting down the machine.