Removing memory

Red Hat Enterprise Linux 9.2 LPAR mode z/VM guest

You can remove memory from your Linux® instance by setting memory blocks offline.

About this task

Avoid removing core memory. The Linux kernel requires core memory to allocate its own data structures.

Procedure

  • Use the chmem command with the -d parameter to set memory offline.
    You can specify the amount of memory you want to remove with the command without specifying particular memory blocks. The tool finds eligible memory blocks for you and sets the most suitable blocks offline.
  • Alternatively, you can write offline to the sysfs state attribute of an unused memory block.
    Issue a command of the form:
    # echo offline > /sys/devices/system/memory/memory<n>/state
    where <n> is an integer that identifies the memory unit.

Results

The hotplug memory functions first relocate memory pages to free the memory block and then remove it. The state attribute changes to offline when the memory block has been removed successfully.

The memory block is not removed if it cannot be freed completely.