chmem - Set memory online or offline

Use the chmem command to set a particular size or range of memory online or offline.

Setting memory online can fail if the hypervisor does not have enough memory left, for example because memory was overcommitted. Setting memory offline can fail if Linux cannot free the memory. If only part of the requested memory can be set online or offline, a message informs you how much memory was set online or offline instead of the requested amount.

chmem syntax

Read syntax diagramSkip visual syntax diagramchmem -e-d <size><start>-<end>

Where:

-e or --enable
sets the specified memory online.
-d or --disable
sets the specified memory offline.
<size>
specifies an amount of memory to be set online or offline. A numeric value without a unit or a numeric value immediately followed by m or M is interpreted as MB (1024 x 1024 bytes). A numeric value immediately followed by g or G is interpreted as GB (1024 x 1024 x 1024 bytes).

The size must be aligned to the memory block size, as shown in the output of the lsmem command.

<start>-<end>
specifies a memory range to be set online or offline. <start> is the hexadecimal address of the first byte and <end> is the hexadecimal address of the last byte in the memory range.

The range must be aligned to the memory block size, as shown in the output of the lsmem command.

-v or --version
displays the version number of chmem, then exits.
-h or --help
displays a short help text, then exits. To view the man page, enter man chmem.

Examples

  • This command requests 1024 MB of memory to be set online.
    # chmem --enable 1024
  • This command requests 2 GB of memory to be set online.
    # chmem --enable 2g
  • This command requests the memory range that starts with 0x00000000e4000000 and ends with 0x00000000f3ffffff to be set offline.
    # chmem --disable 0x00000000e4000000-0x00000000f3ffffff