올바른 메모리 크기를 찾는 방법은 무엇입니까?

올바른 메모리 크기를 찾는 방법은 무엇입니까?

우리는 32G Linux 머신을 가지고 있습니다. 우리는 다음과 같이 메모리를 캡처합니다.

mem=` cat /proc/meminfo | grep MemTotal | awk '{print $2}' `
echo $mem
32767184

이제 이를 GIGA로 변환합니다.

mem_in_giga=`  echo $(( $mem / 1024 / 1024)) `
echo $mem_in_giga
31

그러나 결과에서 우리는 32G가 아닌 31을 얻습니다.

명령과 같은 이야기 free:

free -g
              total        used        free      shared  buff/cache   available
Mem:             31           9          17           0           4          20
Swap:             7           0           7

그렇다면 명령에서 "32G"를 어떻게 얻을 수 있습니까?

답변1

MemTotal 프로그램

사용 가능한 총 RAM 양(즉, 물리적 RAM에서 일부 예약된 비트와 커널 바이너리 코드를 뺀 값)입니다.

경험적 방법을 사용하는 경우를 제외하고는 이를 사용하여 정확한 설치된 메모리를 확인할 수 없습니다.

실제 설치된 메모리를 확인하려면 lshw또는 를 사용하여 dmidecode설치된 모듈의 크기를 표시해야 합니다.예를 들어에서 lshw:

 *-memory
      description: System Memory
      physical id: 4c
      slot: System board or motherboard
      size: 32GiB
      capabilities: ecc
      configuration: errordetection=ecc

또는 더 간결한 형식( lshw -class memory -short):

H/W path           Device      Class          Description
=========================================================
/0/0                           memory         64KiB BIOS
/0/47/48                       memory         256KiB L1 cache
/0/47/49                       memory         1MiB L2 cache
/0/47/4a                       memory         8MiB L3 cache
/0/4c                          memory         32GiB System Memory
/0/4c/0                        memory         8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/4c/1                        memory         8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/4c/2                        memory         8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/4c/3                        memory         8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns)

관련 정보