Linux and Memory
 

Linux and Memory

 

This post was last updated on May 26th, 2020 at 10:10 pm


Determining if your entire memory is being detected:

Use one of the following commands:

  • Use the “free” command
  • free
  • Check in /proc/meminfo
  • cat /proc/meminfo
  • Use the “dmesg” command
  • dmesg
  • Check what the kernel displays on boot up
  • After the kernel loads, press Shift+PgUp and/or Shift+PgDn to view previous screen messages. The memory messages is at the very beginning of the kernel boot up procedure.

    Note: Once you switch away from a console screen, you may no longer use Shift+PgUp to view previous screen messages. Therefore it may be necessary to prevent the GUI from starting after the kernel loads. This can be accomplished in one of several ways:

    • Enter “Single User Maintenance Mode” (runlevel 1):
    • linux S
    • Enter text mode if installing Linux:
    • linux text


METHOD1
METHOD2
METHOD3


Specifying Undetected Memory – Method #1

Note: For Red Hat 7.1 and above (kernel 2.4.x and above) try Method #3 first.

If your entire memory is not detected automatically, then you can specify memory at the boot: prompt or as an append line in /etc/lilo.conf.

Note: This usually occurs on machines with EISA in them. Machines that do not have any EISA slots usually detect all installed memory.

Note: This method #1 is to be used if you do not see memory above 16MB. If you are having problems trying to see memory over 1GB of memory then please read a different section on this page.

The following format is for use at the boot: prompt:

Red Hat 7.0 and prior
mem=128M

The following format is for use as part of an append statement in /etc/lilo.conf:

Red Hat 7.0 and prior
append=”mem=128M”


METHOD1
METHOD2
METHOD3


Specifying Undetected Memory – Method #2

Note: For Red Hat 7.1 and above (kernel 2.4.x and above) try Method #3 first.

On servers that don’t detect above 16MB, here is an alternate method that may work as well as Method #1:

mem=exactmap [email protected] [email protected]

I translated the above values here for easier reading:

0x9f000 = 651264 bytes = 636k
0xA0000 = 655360 bytes = 640k
0x13f00000 = 334495744 bytes = 326656k = 319M
0x14000000 = 335544320 bytes = 327680k = 320M
0x100000 = 1048576 bytes = 1024k = 1M

[email protected]” will set up the lower 640k.
[email protected]” will set up from 1M to 320M

As far as I can tell, the above states to start at 1M and go out 319M. This will give you a total of 319M + the lower 640k

The above values will work (as shown if you have 320M), but I will need to double check exactly how much memory is being detected by using this method.

It appears that the method to calculate a value is to take your mem in MB, multiply by 1024, multiply by 1024, then convert to hex, then subtract 0x100000.

Here’s an example:

For 128M:

128       *   1024     = 131072
131072    *   1024     = 134217728
134217728 ->  Hex      = 0x8000000
0x8000000 -   0x100000 = 0x7F00000

Then you would use:

mem=exactmap [email protected] [email protected]
For 256M:

256M         *   1024     = 262144
262144       *   1024     = 268435456
268435456    ->  Hex      = 0x10000000
0x10000000   -   0x100000 = 0xFF00000

Then you would use:

mem=exactmap [email protected] [email protected]

The other method that should arrive at the same number is to take your mem in MB, subtract 1MB, multiply by 1024, multiply by 1024, then convert to hex.

256M       -   1     = 255
255        *   1024  = 261120
261120     *   1024  = 267386880
267386880  ->  Hex   = 0xFF00000

Here are some samples using Method #2:

16M: linux mem=exactmap [email protected] [email protected]
32M: linux mem=exactmap [email protected] [email protected]
48M: linux mem=exactmap [email protected] [email protected]
64M: linux mem=exactmap [email protected] [email protected]
80M: linux mem=exactmap [email protected] [email protected]
96M: linux mem=exactmap [email protected] [email protected]
112M: linux mem=exactmap [email protected] [email protected]
128M: linux mem=exactmap [email protected] [email protected]
144M: linux mem=exactmap [email protected] [email protected]
160M: linux mem=exactmap [email protected] [email protected]
176M: linux mem=exactmap [email protected] [email protected]
192M: linux mem=exactmap [email protected] [email protected]
208M: linux mem=exactmap [email protected] [email protected]
224M: linux mem=exactmap [email protected] [email protected]
240M: linux mem=exactmap [email protected] [email protected]
256M: linux mem=exactmap [email protected] [email protected]
512M: linux mem=exactmap [email protected] [email protected]


METHOD1
METHOD2
METHOD3


Specifying Undetected Memory – Method #3

This is basically method #2, but in a more readable format.

For a machine with 48M of memory you would use the following:

linux mem=exactmap [email protected] [email protected]

96M

linux mem=exactmap [email protected] [email protected]

128M

linux mem=exactmap [email protected] [email protected]

256M

linux mem=exactmap [email protected] [email protected]

Read Method #2 if you need a better understanding of how this memory command works.

Thanks to NKJensen, Denmark for helping us out with this one!

NKJensen, Denmark also found the following properties about using this method in /etc/lilo.conf:

  • If you put the “append=” line in the global section of /etc/lilo.conf (the section at the very top of /etc/lilo.conf before the individual boot images), it will apply to all boot images in /etc/lilo.conf.
  • A space seems to be required at the beginning of the quotes of the append line:
  • append=" mem=exactmap [email protected] [email protected]"
    
  • As always don’t forget to run /sbin/lilo once you finish making changes to /etc/lilo.conf.

Here are some samples using Method #3:

32M: linux mem=exactmap [email protected] [email protected]
48M: linux mem=exactmap [email protected] [email protected]
64M: linux mem=exactmap [email protected] [email protected]
96M: linux mem=exactmap [email protected] [email protected]
128M: linux mem=exactmap [email protected] [email protected]
256M: linux mem=exactmap [email protected] [email protected]
512M: linux mem=exactmap [email protected] [email protected]


Installing with more than 1GB of memory:

It is not wise to have the installer use more than 1GB of memory. The installer may not be configured to handle it and may get confused and abort. Limit the amount of memory that the installer sees to 960M. The following may be keyed in at the boot prompt:

mem=960M


Gaining access to more than 1GB of memory:

If your system isn’t detecting more than 1GB of memory then there are several ways to get around this:

  • Install the Enterprise-kernel – this has support for more memory built in already
  • Recompile the kernel choosing either 1GB, 2GB or 4GB during configuration
  • Recompile the kernel enabling bigmem


Linux Kernel 2.4 Notes

Here are some excerpts from the file: arch/i386/kernel/setup.c

459-474:
/*
 * Copy the BIOS e820 map into a safe place.
 *
 * Sanity-check it while we're at it..
 *
 * If we're lucky and live on a modern system, the setup code
 * will have given us a memory map that we can use to properly
 * set up memory.  If we aren't, we'll fake a memory map.
 *
 * We check to see that the memory map contains at least 2 elements
 * before we'll use it, because the detection code in setup.S may
 * not be perfect and most every PC known to man has two memory
 * regions: one from 0 to 640k, and one from 1mb up.  (The IBM
 * thinkpad 560x, for example, does not cooperate with the memory
 * detection code.)
 */

520-525:
	/*
	 * Try to copy the BIOS-supplied E820-map.
	 *
	 * Otherwise fake a memory map; one section from 0k->640k,
	 * the next section from 1mb->appropriate_mem_k
	 */

558-564:
		/*
		 * "mem=nopentium" disables the 4MB page tables.
		 * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
		 * to <mem>, overriding the bios size.
		 * "mem=XXX[KkmM]@XXX[KkmM]" defines a memory region from
		 * <start> to <start>+<mem>, overriding the bios size.
		 */

577-582:
				/* If the user specifies memory size, we
				 * limit the BIOS-provided memory map to
				 * that size. exactmap can be used to specify
				 * the exact map. mem=number can be used to
				 * trim the existing memory map.
				 */

prev next cpq Linux


Previous Manual NIC Setup
Next DHCPD Quick Setup Instructions
 

About author

shibaa987
shibaa987 243 posts

Linux kernel developer and a firmware developer with an experience of 10+ years.

View all posts by this author →

You might also like

System Internals 0 Comments

Static Routes in RH73 Linux

This post was last updated on June 3rd, 2020 at 04:36 pm(Other routing page: routes.html) Here’s how to set up Red Hat 7.3 /etc/sysconfig/static-routes file, I mention this here because

System Internals 0 Comments

Linux /dev Entries

This post was last updated on June 1st, 2020 at 11:57 amLocated here is a listing of the /dev directory. I have posted this information since you may not always

System Internals 0 Comments

Difference Between MBR And GPT

Large storage disks usually have logical partitions. An Operating System uses a partition table to identify the start address, filesystem information, and other details of a specific logical partition. The

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply