How to manage memory hotplug using lsmem and chmem commands ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7.5
  • Red Hat Enterprise Linux 8
    • util-linux

Issue

  • How to manage memory hotplug using lsmem and chmem commands ?
  • How to set a particular size or range of memory online or offline ?

Resolution

  • The lsmem command lists the ranges of available memory with their online status

  • The lsmem command also shows the memory block size, the device size, and the amount of memory in online and offline state

  • The chmem command to set a particular size or range of memory online or offline

Example:

# lsmem
RANGE                                  SIZE  STATE REMOVABLE   BLOCK
0x0000000000000000-0x0000000007ffffff  128M online        no       0
0x0000000008000000-0x0000000027ffffff  512M online       yes     1-4
0x0000000028000000-0x0000000037ffffff  256M online        no     5-6
0x0000000038000000-0x00000000b7ffffff    2G online       yes    7-22
0x00000000b8000000-0x00000000bfffffff  128M online        no      23
0x0000000100000000-0x0000000107ffffff  128M online        no      32
0x0000000108000000-0x0000000137ffffff  768M online       yes   33-38
0x0000000138000000-0x000000013fffffff  128M online        no      39
0x0000000140000000-0x00000003e7ffffff 10.6G online       yes  40-124
0x00000003e8000000-0x0000000447ffffff  1.5G online        no 125-136
0x0000000448000000-0x00000007efffffff 14.6G online       yes 137-253
0x00000007f0000000-0x000000080fffffff  512M online        no 254-257
0x0000000810000000-0x000000081fffffff  256M online       yes 258-259    <<--------
0x0000000820000000-0x000000083fffffff  512M online        no 260-263

Memory block size:       128M
Total online memory:      32G
Total offline memory:      0B
  • To set the online memory to offline, use:
# chmem -d 0x0000000810000000-0x000000081fffffff
  • To list the ranges of available memory with their online status
# lsmem
RANGE                                  SIZE   STATE REMOVABLE   BLOCK
0x0000000000000000-0x0000000007ffffff  128M  online        no       0
0x0000000008000000-0x0000000027ffffff  512M  online       yes     1-4
0x0000000028000000-0x0000000037ffffff  256M  online        no     5-6
0x0000000038000000-0x00000000b7ffffff    2G  online       yes    7-22
0x00000000b8000000-0x00000000bfffffff  128M  online        no      23
0x0000000100000000-0x0000000107ffffff  128M  online        no      32
0x0000000108000000-0x0000000137ffffff  768M  online       yes   33-38
0x0000000138000000-0x000000013fffffff  128M  online        no      39
0x0000000140000000-0x00000003e7ffffff 10.6G  online       yes  40-124
0x00000003e8000000-0x00000003efffffff  128M  online        no     125
0x00000003f0000000-0x00000003f7ffffff  128M  online       yes     126
0x00000003f8000000-0x00000003ffffffff  128M  online        no     127
0x0000000400000000-0x0000000407ffffff  128M  online       yes     128
0x0000000408000000-0x0000000447ffffff    1G  online        no 129-136
0x0000000448000000-0x00000007efffffff 14.6G  online       yes 137-253
0x00000007f0000000-0x000000080fffffff  512M  online        no 254-257
0x0000000810000000-0x000000081fffffff  256M offline         - 258-259   <<--------
0x0000000820000000-0x000000083fffffff  512M  online        no 260-263

Memory block size:       128M
Total online memory:    31.8G
Total offline memory:    256M
  • To set the offline memory to online, use:
# chmem -e 0x0000000810000000-0x000000081fffffff
  • To list the ranges of available memory with their online status
# lsmem
RANGE                                  SIZE  STATE REMOVABLE   BLOCK
0x0000000000000000-0x0000000007ffffff  128M online        no       0
0x0000000008000000-0x0000000027ffffff  512M online       yes     1-4
0x0000000028000000-0x0000000037ffffff  256M online        no     5-6
0x0000000038000000-0x00000000b7ffffff    2G online       yes    7-22
0x00000000b8000000-0x00000000bfffffff  128M online        no      23
0x0000000100000000-0x0000000107ffffff  128M online        no      32
0x0000000108000000-0x0000000137ffffff  768M online       yes   33-38
0x0000000138000000-0x000000013fffffff  128M online        no      39
0x0000000140000000-0x00000003dfffffff 10.5G online       yes  40-123
0x00000003e0000000-0x00000003efffffff  256M online        no 124-125
0x00000003f0000000-0x00000003f7ffffff  128M online       yes     126
0x00000003f8000000-0x00000003ffffffff  128M online        no     127
0x0000000400000000-0x000000040fffffff  256M online       yes 128-129
0x0000000410000000-0x0000000447ffffff  896M online        no 130-136
0x0000000448000000-0x00000007f7ffffff 14.8G online       yes 137-254
0x00000007f8000000-0x000000080fffffff  384M online        no 255-257
0x0000000810000000-0x000000081fffffff  256M online       yes 258-259    <<--------
0x0000000820000000-0x000000083fffffff  512M online        no 260-263

Memory block size:       128M
Total online memory:      32G
Total offline memory:      0B

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.