📜 ⬆️ ⬇️

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 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:

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


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.

  1. 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 
  2. 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.
  3. 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.
  4. 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.
  5. 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:
     #!/bin/sh cp /home/vm/workstation/ramtemp.vmdk.new /run/shm/ramtemp.vmdk vmplayer /home/vm/workstation/workstation.vmx 
  6. 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.

Source: https://habr.com/ru/post/153033/


All Articles