Linux常用命令-lsmem

命令

lsmem

描述

list the ranges of available memory with their online status
显示内存状态

用法

1
lsmem [options]

选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Options:
-P, --pairs 显示格式为key="value"
-a, --all 显示每个单独的存储块
-b, --bytes SIZE显示为bytes
-n, --noheadings 不显示头部标题
-o, --output <list> 显示指定格式
-r, --raw 显示原始格式
-S, --split <list> 按指定列划分范围
-s, --sysroot <dir> 指定系统根目录
--summary[=when] 显示汇总信息,可选项为(never,always or only)

-o可选的字段列表如下
RANGE start and end address of the memory range
SIZE size of the memory range
STATE online status of the memory range
REMOVABLE memory is removable
BLOCK memory block number or blocks range
NODE numa node of memory
ZONES valid zones for the memory range

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$ lsmem 
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000007ffffff 128M online no 0
0x0000000008000000-0x000000002fffffff 640M online yes 1-5
0x0000000030000000-0x000000003fffffff 256M online no 6-7
0x0000000040000000-0x0000000067ffffff 640M online yes 8-12
0x0000000068000000-0x000000007fffffff 384M online no 13-15

Memory block size: 128M
Total online memory: 2G
Total offline memory: 0B
# -P显示格式为key="value"
$ lsmem -P
RANGE="0x0000000000000000-0x0000000007ffffff" SIZE="128M" STATE="online" REMOVABLE="no" BLOCK="0"
RANGE="0x0000000008000000-0x000000002fffffff" SIZE="640M" STATE="online" REMOVABLE="yes" BLOCK="1-5"
RANGE="0x0000000030000000-0x000000003fffffff" SIZE="256M" STATE="online" REMOVABLE="no" BLOCK="6-7"
RANGE="0x0000000040000000-0x000000006fffffff" SIZE="768M" STATE="online" REMOVABLE="yes" BLOCK="8-13"
RANGE="0x0000000070000000-0x000000007fffffff" SIZE="256M" STATE="online" REMOVABLE="no" BLOCK="14-15"
# -a显示所有存储块
$ lsmem -a
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000007ffffff 128M online no 0
0x0000000008000000-0x000000000fffffff 128M online yes 1
...
0x0000000060000000-0x0000000067ffffff 128M online yes 12
0x0000000068000000-0x000000006fffffff 128M online no 13
0x0000000070000000-0x0000000077ffffff 128M online no 14
0x0000000078000000-0x000000007fffffff 128M online no 15

Memory block size: 128M
Total online memory: 2G
Total offline memory: 0B
# -b显示单位为字节
$ lsmem -b
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000007ffffff 134217728 online no 0
0x0000000008000000-0x000000002fffffff 671088640 online yes 1-5
0x0000000030000000-0x000000003fffffff 268435456 online no 6-7
0x0000000040000000-0x0000000067ffffff 671088640 online yes 8-12
0x0000000068000000-0x000000007fffffff 402653184 online no 13-15

Memory block size: 134217728
Total online memory: 2147483648
Total offline memory: 0
# -n不显示标题
$ lsmem -n
0x0000000000000000-0x0000000007ffffff 128M online no 0
0x0000000008000000-0x000000002fffffff 640M online yes 1-5
0x0000000030000000-0x000000003fffffff 256M online no 6-7
0x0000000040000000-0x0000000067ffffff 640M online yes 8-12
0x0000000068000000-0x000000007fffffff 384M online no 13-15

Memory block size: 128M
Total online memory: 2G
Total offline memory: 0B
# -r显示原始格式
$ lsmem -r
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000007ffffff 128M online no 0
0x0000000008000000-0x000000002fffffff 640M online yes 1-5
0x0000000030000000-0x000000003fffffff 256M online no 6-7
0x0000000040000000-0x0000000067ffffff 640M online yes 8-12
0x0000000068000000-0x000000007fffffff 384M online no 13-15
# 只显示内存汇总信息
$ lsmem --summary=only
Memory block size: 128M
Total online memory: 2G
Total offline memory: 0B