We have some tests we need to run in a server with 32Gb RAM.
All the servers we have access to have 64GB and we can't physically change this.
Is there some way of telling RHEL to use only some fixed amount of RAM, less than what is installed?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Boot with the kernel parameter
mem=nn[KMG][KNL,BOOT] Force usage of a specific amount of memory
Amount of memory to be used when the kernel is not able to see the whole system memory or for test. [X86] Work as limiting max address. Use together with memmap= to avoid physical address space collisions. Without memmap= PCI devices could be placed at addresses belonging to unused RAM.
Yes, you can allocate a fixed amount of RAM for testing purposes on a server with more physical RAM than you need. To do this, you can use control groups (cgroups) in Red Hat Enterprise Linux (RHEL) to limit the amount of memory that a specific process or group of processes can use.
Here's a step-by-step guide on how to limit the RAM usage for a specific process or group of processes:
Install and Enable
If you haven't already, you may need to install the
sudo yum install libcgroup-tools
Create a Memory Cgroup:
Create a new cgroup for your test processes:
sudo cgcreate -g memory:/mytestgroup
/mytestgroup with the desired cgroup name.
Limit Memory Usage:
Set memory limits for the cgroup. For example, to limit it to 16GB of RAM:
sudo cgset -r memory.limit_in_bytes=16G mytestgroup
Adjust the limit to the amount of RAM you want to allocate for your tests.
Move Your Process(es) to the Cgroup:
You'll need to move the processes you want to limit to the cgroup. You can do this by specifying the cgroup for the process or by using the
cgexec command. For example, to run a command in the
sudo cgexec -g memory:mytestgroup your_test_command
your_test_command with the actual command you want to run as part of your tests.
Monitor Memory Usage:
You can monitor the memory usage of the cgroup and its processes using the
sudo cgget -g memory:mytestgroup
This will display information about memory usage, including the memory limit and current usage.
When your tests are complete, you can remove the cgroup:
sudo cgdelete memory:mytestgroup
This will remove the cgroup and release the memory limits.
By following these steps, you can effectively limit the amount of RAM that specific processes or groups of processes can use on a server with more physical RAM than you need for your testing purposes. This allows you to isolate and control the resources allocated to your test processes without the need to physically change the server's hardware configuration.