Skip to content
Service Servers

Service Servers

  • Cloudbase Solutions
  • Service Servers
Service Servers
Service Servers
Home / Linux / Troubleshooting VM RAM Allocation Error
Linux

Troubleshooting VM RAM Allocation Error

The error you’re encountering (Cannot allocate memory) typically occurs when QEMU/KVM is unable to allocate the requested amount of memory (128GB in this case) for the VM. Here are some steps to troubleshoot and resolve the issue: 1. Check Host Memory Availability 2. Check Kernel Memory Overcommit Settings 3. Check Swap Space 4. Check QEMU/KVM…

The error you’re encountering (Cannot allocate memory) typically occurs when QEMU/KVM is unable to allocate the requested amount of memory (128GB in this case) for the VM. Here are some steps to troubleshoot and resolve the issue:

1. Check Host Memory Availability

  • Ensure the host system actually has 128GB of free RAM available. The host OS and other processes also consume memory.
  • Run free -h or top on the host to check available memory.
  • If the host is using some memory, you may need to reduce the VM’s RAM slightly (e.g., 127GB) or free up host memory.

2. Check Kernel Memory Overcommit Settings

  • Linux has a memory overcommit policy that may prevent QEMU from allocating large chunks of memory.
  • Check the current overcommit mode:
    cat /proc/sys/vm/overcommit_memory
    • 0 = heuristic overcommit (default, may block large allocations)
    • 1 = always overcommit (risky)
    • 2 = strict no-overcommit (denies allocations if not enough RAM + swap)
  • Temporarily set overcommit to 1 (for testing):
    echo 1 > /proc/sys/vm/overcommit_memory
  • To make this permanent, add to /etc/sysctl.conf:
    vm.overcommit_memory = 1
    Then run sysctl -p.

3. Check Swap Space

  • Ensure the host has sufficient swap space to handle the allocation (even if you don’t want the VM using swap, the host may need it for accounting).
  • Run swapon --show or free -h to check swap.
  • Add swap if needed (e.g., 4-8GB as a safety buffer).

4. Check QEMU/KVM Limits

  • Some systems impose limits on per-process memory allocation.
  • Check ulimit -a for the max locked memory setting (should be unlimited or >= 128GB for the user running QEMU).
  • Adjust limits in /etc/security/limits.conf:
    <user running qemu> hard memlock unlimited
    <user running qemu> soft memlock unlimited
  • Re-login or restart the service for changes to take effect.

5. Enable Huge Pages (Recommended for Large RAM VMs)

  • Huge Pages improve performance and help with large memory allocations.
  • Allocate huge pages (e.g., for 128GB = 65536 2MB pages):
    echo 65536 > /proc/sys/vm/nr_hugepages
  • Make this permanent in /etc/sysctl.conf:
    vm.nr_hugepages = 65536
  • Verify with grep HugePages_ /proc/meminfo.
  • Configure the VM to use huge pages in its XML (if using libvirt) or via SolusVM’s advanced options.

6. Check SolusVM Configuration

  • Ensure SolusVM is configured to allow VMs with 128GB RAM.
  • Edit /usr/local/solusvm/includes/settings.php and check:
    define('MEMORY_LIMIT', '128000'); // or higher
  • Restart SolusVM services after changes.

7. Verify QEMU/KVM Version

  • Older versions may have issues with large memory allocations.
  • Update QEMU/KVM to the latest version:
    bash yum update qemu-kvm libvirt # For CentOS/RHEL apt-get update && apt-get upgrade qemu-kvm libvirt-bin # For Debian/Ubuntu

8. Test with a Smaller VM First

  • Try creating a VM with 64GB RAM to isolate whether the issue is specific to 128GB.

9. Host Kernel Parameters

  • Add vm.nr_overcommit_hugepages to /etc/sysctl.conf:
    vm.nr_overcommit_hugepages = 65536
  • Run sysctl -p to apply.

10. Debug QEMU

  • Run QEMU manually with debug logging to see the exact failure:
    bash qemu-kvm -m 131072 -enable-kvm -name test-vm -monitor stdio
  • Check logs in /var/log/libvirt/qemu/ or SolusVM’s logs.

Final Notes:

  • If the host has exactly 128GB RAM, you may need to leave some memory for the host OS (e.g., 126GB for the VM).
  • For production workloads, consider using a host with >128GB RAM (e.g., 144GB) to avoid overcommit issues.

After applying these changes, try recreating the VM in SolusVM. If the issue persists, check SolusVM-specific logs (usually in /usr/local/solusvm/data/logs/).

Post navigation

Previous Previous
Synchronize files between servers
  • Troubleshooting VM RAM Allocation Error
  • Synchronize files between servers
  • Check folder and disk size in Linux command
  • IP Tables Block IP and Port
  • .htaccess SSL check problems

    Copyright © 2025 Service Servers

    • Cloudbase Solutions
    • Service Servers
    Search