Using more than 4GB of RAM in 32 bit guest operating systems


It's no secret that 32-bit operating systems do not allow addressing more than 4GB of RAM. Now I want to tell you how this restriction can be circumvented indirectly in a virtual environment where there is full access to the host operating system.

Actually, the goal is quite clear - it is to allow the guest x32 operating system to use in addition to the “honest” 4GB of RAM some more that can be painlessly allocated from the available one.

To begin, I will describe a short plan for achieving the goal, and then consider the details and implementation. But I’ll immediately make a reservation that this method, of course, will not allow the operating system to “see” more memory than it can afford, but it will be used invisibly for itself.

Let's start

Initial data:
  • Host: Ubuntu 12.04 x64, RAM 8Gb
  • VM: VMware Player 4.0.4
  • Guest: Windows XP SP3 x32, RAM 3Gb

We will “allocate” additional RAM in an unusual way. To do this, create a vmdk disk and place it in the RAM of the host system. We will connect the created disk to the guest system. To start the full use of additional RAM, it remains only to move the swap file to this disk. In addition to transferring the swap file, you can reconfigure some programs to store their caches or temporary files in this "RAM", but this already depends on its size.

Some details

  • The size of the created vmdk disk can be calculated as follows:
    (RAM available to the host system) - (RAM transferred to the VM) - k
    where k is the minimum required amount of RAM for the host system to work.
  • Since the vmdk disk must be located in RAM, it should be placed there at least every time after loading the system
  • Since I / O operations in RAM are quite fast, there is no need to create a preallocated (i.e. with a pre-allocated location) vmdk disk file.
  • It is desirable that the configuration of the page file contains its minimum and maximum size, approximately equal to the size of the created vmdk disk. This size will slightly differ from the specified volume when creating vmdk, since part of the space will be occupied by the file system and service information of the system itself.
  • To place a vmdk file in RAM, you need to prepare this memory for access to it from the file system.
  • In most cases, when using this tuning, it will no longer be possible to use the Suspend function in vmplayer.

An interesting fact: if the vmdk disk was not preallocated (ie, “rubber”), and the swap file was configured as described above, that is, the maximum and fixed size, then despite the fact that the swap file occupies all the space vmdk disk, in the host this vmdk file will take up space almost the same as before transferring the swap file to it. Naturally, this cannot but please, as the guest system will use additional RAM as needed, however, only in the direction of increase.

And now step by step instructions for the configuration described above

  1. We configure the host file system so that through it we get access to all the RAM. To do this, /etc/fstabadd the following line to the file:
    tmpfs /run/shm tmpfs size=8G 0 0
  2. We create a single-file, not preallocated vmdk disk. Specify the size of 3Gb and save it in /run/shmwith a name ramtemp.vmdk. After creating, disable caching of recording on this disk.
  3. We load the virtual machine. We create the main partition on the disk that appeared in the guest system, format it and mark it as ramtemp . Mount it in a previously created folder c:\ramtemp. Yes, yes, this can also be done on Windows, this is when instead of selecting a drive letter, the option “Mount volume as an empty NTFS folder” is selected. Connection to the folder is done so as not to produce unnecessary “letter drives” in the system. You should also disable the indexing of this disk in its properties. After that, turn off the virtual machine.
  4. Next, /run/shm/ramtemp.vmdkcopy the prepared one to the folder with the target virtual machine and rename it to ramtemp.vmdk.new. This is done in order not to accidentally connect this disk to a virtual machine and not start using it. This disk is always necessary in its original form in order to occupy its minimum size.
  5. For all subsequent launches of the virtual machine, you need to create a script that will automatically copy clean ramtemp.vmdkto virtual memory and start the virtual machine before starting . For example, it could be like this:
    #!/bin/sh
    cp /home/vm/workstation/ramtemp.vmdk.new /run/shm/ramtemp.vmdk
    vmplayer /home/vm/workstation/workstation.vmx 
  6. We start the virtual machine again and move the swap file to the “RAM”. To do this, go to the registry branch HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Managementand change the path to c:\ramtemp\pagefile.systhe page file in the PagingFiles parameter . After all the above, you need to restart the guest OS.

After completing all the steps, you can consider your virtual machine officially pumped.

Also popular now: