
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 clear enough - it is to allow the guest x32 operating system to use, in addition to “honest” 4GB of RAM, some more that can be painlessly made available.
To begin, I will describe a brief plan for achieving the goal, and then consider the details and implementation. But at once I will make a reservation that this method, of course, will not allow the operating system to “see” more memory than it can afford, but now it will be used unnoticed by 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 host system’s RAM. The created disk will be connected to the guest system. To start the full use of additional RAM will only move to the disk swap file. In addition to transferring the paging 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 vmdk disk created can be calculated as follows:
(RAM available to host system) - (RAM transferred by VM) - k
where k is the minimum required amount of RAM for the host system to work. - Since the vmdk disk should be located in RAM, it should be placed there at least every time after booting the system.
- Since I / O operations in RAM are fast enough, there is no need to create a pre-local (i.e., with a pre-allocated space) disk vmdk file.
- It is desirable that the configuration of the paging file contains the minimum and maximum size, approximately equal to the volume created by the vmdk disk. This size will differ slightly from the specified volume when creating a vmdk, since part of the space will be taken by the file system and the service information of the system itself.
- To place a vmdk file in RAM, you need to prepare this memory to access it from the file system.
- In most cases, when using such tuning, it will no longer be possible to use the “Suspend” function in vmplayer.
An interesting fact: if the vmdk disk was not made preallocated (i.e. “rubber”), and the paging file was configured as described above, that is, maximum and fixed size, then, despite the fact that the paging file will take up 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 can not fail to please, as the guest system will use additional RAM as needed, but only upwards.
And now step by step instructions for the configuration described above.
- We configure the host file system so that through it we have access to all the RAM. To do this, add the following line to the
/etc/fstab
:
tmpfs /run/shm tmpfs size=8G 0 0
- Create a single-file, non-preallocated vmdk disk. Specify the size of 3Gb and save it to
/run/shm
with the name ramtemp.vmdk
. After creation, turn off write caching on this disk. - We load the virtual machine. Create a primary partition that appears in the guest system, format it and mark it as ramtemp . Mount it in the previously created folder
c:\ramtemp
. Yes, yes, in Windows, you can also do this, this is when instead of selecting the drive letter, select the item “Connect volume as an empty NTFS folder”. Connecting to a folder is done in order not to produce in the system unnecessary unused “alphabetic disks”. Also, you should disable the indexing of this disk in its properties. After that, turn off the virtual machine. - Next, copy the
/run/shm/ramtemp.vmdk
into 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 disc is always necessary in its original form in order to occupy its minimum volume. - For all subsequent launches of the virtual machine, you need to create a script that will automatically copy clean
ramtemp.vmdk
to virtual memory and start the virtual machine before starting. For example, it might be:
- Start the virtual machine again and move the paging file to the “RAM”. To do this, go to the registry branch
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
and change the path to the paging file to c:\ramtemp\pagefile.sys
in the PagingFiles parameter. After all done above, you need to restart the guest OS.
After completing all the steps, you can consider your virtual machine officially pumped.