how to find the right memory size

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












we have linux machine with 32G



we capture the mem as the follwing



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


and now we convert it to GIGA



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


but from results we get 31 and not 32G



the same story with free command



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


so how to get the 32G by any command solution?







share|improve this question


















  • 1




    You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
    – muru
    Feb 1 at 12:39







  • 1




    Also, it's unclear what numbers are GB and what number may be GiB.
    – Kusalananda
    Feb 1 at 12:47






  • 1




    free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
    – Stephen Kitt
    Feb 1 at 12:53






  • 1




    Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
    – Patrick
    Feb 1 at 13:20







  • 1




    For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
    – Sergiy Kolodyazhnyy
    Feb 1 at 15:52














up vote
0
down vote

favorite












we have linux machine with 32G



we capture the mem as the follwing



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


and now we convert it to GIGA



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


but from results we get 31 and not 32G



the same story with free command



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


so how to get the 32G by any command solution?







share|improve this question


















  • 1




    You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
    – muru
    Feb 1 at 12:39







  • 1




    Also, it's unclear what numbers are GB and what number may be GiB.
    – Kusalananda
    Feb 1 at 12:47






  • 1




    free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
    – Stephen Kitt
    Feb 1 at 12:53






  • 1




    Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
    – Patrick
    Feb 1 at 13:20







  • 1




    For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
    – Sergiy Kolodyazhnyy
    Feb 1 at 15:52












up vote
0
down vote

favorite









up vote
0
down vote

favorite











we have linux machine with 32G



we capture the mem as the follwing



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


and now we convert it to GIGA



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


but from results we get 31 and not 32G



the same story with free command



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


so how to get the 32G by any command solution?







share|improve this question














we have linux machine with 32G



we capture the mem as the follwing



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


and now we convert it to GIGA



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


but from results we get 31 and not 32G



the same story with free command



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


so how to get the 32G by any command solution?









share|improve this question













share|improve this question




share|improve this question








edited Feb 1 at 12:43









Jeff Schaller

31.4k846105




31.4k846105










asked Feb 1 at 12:33









yael

1,9871145




1,9871145







  • 1




    You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
    – muru
    Feb 1 at 12:39







  • 1




    Also, it's unclear what numbers are GB and what number may be GiB.
    – Kusalananda
    Feb 1 at 12:47






  • 1




    free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
    – Stephen Kitt
    Feb 1 at 12:53






  • 1




    Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
    – Patrick
    Feb 1 at 13:20







  • 1




    For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
    – Sergiy Kolodyazhnyy
    Feb 1 at 15:52












  • 1




    You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
    – muru
    Feb 1 at 12:39







  • 1




    Also, it's unclear what numbers are GB and what number may be GiB.
    – Kusalananda
    Feb 1 at 12:47






  • 1




    free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
    – Stephen Kitt
    Feb 1 at 12:53






  • 1




    Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
    – Patrick
    Feb 1 at 13:20







  • 1




    For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
    – Sergiy Kolodyazhnyy
    Feb 1 at 15:52







1




1




You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
– muru
Feb 1 at 12:39





You don't have a machine with 32 GB RAM. You have machine with approximately 32 GB RAM. If you really want 32: echo $((32767184/1000/1000)).
– muru
Feb 1 at 12:39





1




1




Also, it's unclear what numbers are GB and what number may be GiB.
– Kusalananda
Feb 1 at 12:47




Also, it's unclear what numbers are GB and what number may be GiB.
– Kusalananda
Feb 1 at 12:47




1




1




free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
– Stephen Kitt
Feb 1 at 12:53




free -g outputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...
– Stephen Kitt
Feb 1 at 12:53




1




1




Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
– Patrick
Feb 1 at 13:20





Just FYI, you can get rid of the cat, grep, and echo: awk '$1 == "MemTotal:" print $2 / 1024 / 1024 ' /proc/meminfo
– Patrick
Feb 1 at 13:20





1




1




For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
– Sergiy Kolodyazhnyy
Feb 1 at 15:52




For future reference on converting byte values, see unix.stackexchange.com/q/44040/85039
– Sergiy Kolodyazhnyy
Feb 1 at 15:52










1 Answer
1






active

oldest

votes

















up vote
7
down vote



accepted










MemTotal shows




Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary
code).




You can’t use that to determine the exact installed memory, except by using heuristics...



To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:



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


or in more compact form (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)





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421193%2fhow-to-find-the-right-memory-size%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    7
    down vote



    accepted










    MemTotal shows




    Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary
    code).




    You can’t use that to determine the exact installed memory, except by using heuristics...



    To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:



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


    or in more compact form (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)





    share|improve this answer


























      up vote
      7
      down vote



      accepted










      MemTotal shows




      Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary
      code).




      You can’t use that to determine the exact installed memory, except by using heuristics...



      To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:



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


      or in more compact form (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)





      share|improve this answer
























        up vote
        7
        down vote



        accepted







        up vote
        7
        down vote



        accepted






        MemTotal shows




        Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary
        code).




        You can’t use that to determine the exact installed memory, except by using heuristics...



        To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:



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


        or in more compact form (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)





        share|improve this answer














        MemTotal shows




        Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary
        code).




        You can’t use that to determine the exact installed memory, except by using heuristics...



        To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:



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


        or in more compact form (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)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 1 at 12:57









        ilkkachu

        49.8k674137




        49.8k674137










        answered Feb 1 at 12:42









        Stephen Kitt

        142k22308370




        142k22308370






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421193%2fhow-to-find-the-right-memory-size%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)