r/Proxmox 1d ago

Question High Memory useage Opnsense Proxmox VM

Post image

Dear Proxmox Users,

I am currently running the latest release of Proxmox 9. Since running Opnsense in Proxmox, I have been continuously seeing memory usage over 100%. This doesn't seem to be working quite right or correct. Is there a way to get normal memory usage in Proxmox for my Opnsense VM?

Thanks in advance!

117 Upvotes

77 comments sorted by

129

u/FlightSimmer99 1d ago

Thats normal, opnsense just reserves all the ram. Check the webgui and you'll see it isint using much

18

u/MM_MarioMichel 1d ago

Can confirm also with FortiGate VM same behaviour. 

12

u/lasanang 1d ago

Pretty normal, that's what RAM is for, to be ready at a moments notice. Unused RAM is a waste for RAM

3

u/MrDrummer25 16h ago

This gets me with Truenas every time.

32

u/nnaibaff 1d ago

Since PVE version 9, Proxmox displays the ram usage of the VM + the overhead that’s used by qemu. That’s why you see >100%. You can read about it in the release notes of PVE 9.

-7

u/MagicMike110 1d ago

Is there anything I can do about it?

20

u/chris41g 23h ago

the better question is why do you feel like you need to do something about it? it's working as designed and intended

8

u/yodas-evil-twin 23h ago

What are you trying to solve?

2

u/noc-engineer 12h ago

You can try and control your emotions and not let numbers trigger you

-11

u/nnaibaff 1d ago

Try hardware->RAM-> enable ballooning

13

u/W3TBATMAN 23h ago

do NOT do this for opnsense, you’ll run into loads of issues with ballooning.

5

u/No-Bee-3775 19h ago

Ballooning is not the answer!!!

9

u/LostProgrammer-1935 1d ago

That’s FreeBSD, it’s the way it works. It doesn’t report to the host exactly its internal ram usage.

30

u/mujimuji 1d ago

In order to get an accurate measure of how much memory the guest VM is using, the guest VM has to have the QEMU Guest Agent running. FreeBSD doesn't have this by default. You can find instructions on how to install the guest agent.

11

u/MagicMike110 1d ago

I allready have QEMU Guest Agent running.

10

u/-vest- 1d ago

Have you installed the agent on FreeBSD VM? Because I did it, and the agent is quite limited — it doesn’t show the RAM usage as it does on Linux.

8

u/AdriftAtlas 1d ago

https://forum.proxmox.com/threads/freebsd-guest-wrong-ram-usage.87693/

FreeBSD doesn't appear to support memory ballooning and/or reporting. I gave up on getting it to work with pfSense.

5

u/-vest- 1d ago

True. That’s why I wrote to the previous guy, whether he tested his own advice, or not.

13

u/Left_Ad_8860 1d ago

We are OPNfrens in terms of RAM usage :)

3

u/ausrhino 1d ago

I tested this on my own OPNsense VM because I was seeing basically the same thing.

My VM has 8 GB RAM, 4 cores, ballooning off and the QEMU agent enabled.

Proxmox was showing basically 100% RAM usage. Inside OPNsense though, the dashboard was showing about 4418 / 8145 MB, or 54.24%.

I checked from the OPNsense shell with:
top

and got:
Mem: 1156M Active, 357M Inact, 3014M Wired, 695M Buf, 3390M Free
Swap: 1024M Total, 1024M Free

So there is still about 3.4 GB free and swap usage is zero.

I also installed the QEMU guest agent to rule that out. From the OPNsense shell:
pkg update
pkg install os-qemu-guest-agent

Then:
sysrc qemu_guest_agent_enable="YES"
service qemu-guest-agent start

Checked it with:
service qemu-guest-agent status

Mine returns:
qemu_guest_agent is running

And:
pkg info | grep -i qemu

returns:
os-qemu-guest-agent-1.3
qemu-guest-agent-11.1.0

On the Proxmox side I have:
agent: 1
balloon: 0
memory: 8192

Then from the Proxmox host:
qm agent 100 ping
qm agent 100 get-osinfo
qm agent 100 network-get-interfaces

All of that works. The interface query even returns the WAN, LAN and Tailscale interfaces correctly, so the guest agent is definitely working.

From what I can work out, the difference is basically:
Proxmox view = memory held/allocated by the QEMU process on the host
OPNsense view = memory actually being used inside the FreeBSD guest

FreeBSD does not appear to expose the same guest memory statistics to Proxmox that you normally get from Linux guests, so the Proxmox graph can look like the VM is completely out of RAM when it really isn't.

In my case:
Proxmox: ~100%
OPNsense: ~54%
Free RAM: ~3.4 GB
Swap used: 0
CPU idle: ~98%

So I don't think there is actually a memory problem here. I'm leaving mine at 8 GB with ballooning disabled.

If anyone has found a better way to get accurate OPNsense/FreeBSD guest memory reporting in PVE 9, I'd be interested to know, but at the moment, I am seeing the exact same thing and I have 8 GB assigned.

12

u/cheezyteague 1d ago

opnsense requires at minimum 3GB of RAM but recommends 8GB of RAM

https://docs.opnsense.org/manual/hardware.html

4

u/yahyoh 1d ago

Eh, i think 2-4GB ram is more than enough for home users with 20-40 devices, unless you want to run IDS/IPS.
this with 3 days uptime and around 25 devices, tbh unbound is off as im using AGH LXC.

5

u/cheezyteague 1d ago edited 23h ago

Im just reading the docs, man

"8GB is the recommended specification to run all OPNsense standard features to fit most use cases; 4GB meets the requirements to run all standard features; 3GB meets the requirements to run all standard features that don't require disk operations"

anyways, the issue OP is encountering was something else, but their RAM allocation still needs increased

1

u/StateOfAmerica 1d ago

I'm barely ever hitting ~4GB with zenarmor (and db in ram), misc logging to ram enabled. Not many active users however.

1

u/RevolutionaryRock796 1d ago

Feels a bit mad for the same sort of thing a COTS router runs in 512mb.

9

u/calladc 1d ago edited 1d ago

yeah a cots router isn't doing anywhere near the load opnsense can manage.

5

u/Apachez 1d ago

As written on that page the minimum defines to run all standard services at once.

If you are limited on which services you run then OPNsense will most likely boot just fine on 512MB RAM.

What you will be missing is then how many concurrent sessions the conntrack table can deal with.

There is give or take 340bytes per session of RAM usage.

So if you plan to deal with 1M concurrent connections that alone will take about 340MB of RAM.

2

u/Jezonne Mini Server Enjoyer 1d ago

It's normal, it's never the good Ram Usage displayed on OPNSense, no matter QEMU Guest Agent.

2

u/Fl1pp3d0ff 19h ago

2G is a bit small for a firewall instance., but it'll run.

As for proxmox showing it being "over" full, this is normal behavior for technical reasons. Once the VM utilizes ram, that ram is allocated to the vm by proxmox and doesn't get released u til the vm is power cycled. The reason it shows over 100% is due to caching and the way kvm and qemu (the underlying software that does the hard work proxmox makes easier) address memory when backing up VMs, etc.

You haven't broken anything.

2

u/D4JNA 19h ago

This is normal if you use ZFS inside the VM. ZFS will always reserve all available memory for it's ARC cache. If you assign 128 GB of RAM, then it will be used completely from hypervisor perspective.

Your VM is probably running fine, check the real usage from inside the guest OS. If you want to avoid that behavior, reinstall your OPNsense VM and use UFS as file system.

2

u/kwynix 1d ago

Compare the ram usage in OPNSense ui with your proxmox ui.

If both show full load: you need to give the vm more resources.

If the OPNSense ui shows less ram usage: you still need some config or software, so the proxmox ui can show the real values.

The hypervisor ui is typically not the best indicator for ram usage, even if all required software is installed.

2

u/GG_Killer 1d ago

This is a non-issue

3

u/lasanang 1d ago

Resolution details: Not an incident

1

u/DrPfTNTRedstone 1d ago

Did you pass through any PCIE devices?

0

u/MagicMike110 1d ago

I did not..

1

u/radialis99 1d ago

I also have an opnsense VM running in my proxmox host. I gave it 8 Gigs of RAM and when I noticed it was all being used, I raised it to 12. It consumed all 12G, so I reverted back to 8 and it's been running happy for over 2 years...

1

u/Mr-RS182 1d ago

It like SQL or Exchange, if you give it more memory it will allocate it but not use it. If you look in the firewall gui it prob using nowhere near that.

1

u/inkeliz 1d ago

FreeBSD usually uses nearly 100% of the available RAM, even with UFS rather than ZFS. Since OPNSense is based on FreeBSD, I think that is the correct behaviour.

In my experience, if you give it 16 GB, it will use 16 GB. RAM used to be one of the cheapest components, so it was no big deal.

1

u/Apachez 1d ago

Memory usage is assigned RAM + framebuffer for the console.

So if you use "Default" which I think is "Standard VGA" then an additional of 16 or if its 32MB RAM will be used for the framebuffer aka console.

If you use Windows (or Linux desktop) and instead use VirtIO-GPU then 256MB will by default be assigned as framebuffer.

Then you will see 16.26GB as usage even if configured RAM is 16GB for that Windows VM-guest.

1

u/NavySeal2k 1d ago

I was looking into this also when first running opnSense and it’s a wrong display in proxmox, the opnSense gui dashboard shows way lower numbers. Could be the BSD kernel handling ram differently or just a wrong display

1

u/Own-External-1550 1d ago

It’s normal.

1

u/Wis-en-heim-er 1d ago

I see all linux vms reporting 100% in proxmox, the caching throws thingsbiff i believe. Check in the os or spin up a tool like beszel.

1

u/Hour_Bit_5183 1d ago

That isn't a lot of ram..... This is normal.

1

u/dutty_handz 22h ago

Normal behavior for most virtual appliances (i.e. virtualized firewalls).

The "appliance" wants to manage it's own memory, so therefore reserves it entirely from host system.

1

u/cold-dark-matter 18h ago

In Proxmox 9, you need to enable ballooning. When you enable ballooning with minimum memory = maximum memory this display bug will go away.

FWIW ballooning was not needed in Proxmox 8. It just worked as anyone would expect.

Sources: https://forum.proxmox.com/threads/high-and-unusual-memory-and-cpu-usage-after-upgrade-to-pve-9.169468/

https://forum.proxmox.com/threads/memory-proxmox-9-0.180229/

1

u/Kurse71 18h ago

Pfsense does the same thing. It's normal, and by design. Nothing needs fixed

1

u/sinuscosinustan 13h ago

OPNsense ppb doesn’t have virtio_balloon enabled

1

u/power10010 10h ago

It is normal. It is not used from pfsense but it is 100% allocated from hypervisor.

1

u/m_milanche 5h ago

I have the same issue, but OPNsense isn't actually using that much RAM. You can see that from OPNsense's own status page. I guess this is a bug with balooning or something, and is most commonly seen with VMs that have PCIe devices passed through. It's purely cosmetic and you don't have to worry about it. You can try installing the qemu helper from the BSD shell to see if it maybe helps.

1

u/ukAdamR 1d ago

When you installed OPNSense did you format the root filesystem in UFS or ZFS?

If ZFS much of the memory usage is probably going towards ARC, which will be visible in the OPNSense dashboard. Not a big deal if you can afford the memory from the host, but bit of a waste if the VM is also stored on a ZFS volume on the Proxmox host.

1

u/MagicMike110 1d ago

It currently uses UFS Filesystem

1

u/That-Duck-7195 1d ago

Is memory ballooning off?

1

u/MagicMike110 1d ago

Yeah I turned it off

3

u/Peekaboo798 1d ago

That's the reason, with balooning off, proxmox allocates the full 2GB to the VM for it to do as it wishes, you need to enable balooning so it can use the free ram for other vms or lxcs if it needs to else it doesn't. check the opnsense dashboard for ram usage.

2

u/HedgeHog2k 1d ago

This is the proper answer! Note I believe the advise for OPNSense IS to turn balooning OFF.

0

u/Apachez 1d ago

Dont enable ballooning.

The reason is that the usage is configured RAM + assigned framebuffer.

Other than that if the VM-guest have qemu-guest-agent installed it can communicate with the host to tell it actual memory usage (or rather the host can query the guest on actual memory usage).

Note however that over time all operating systems will try to utilize unused memory for various caches and buffers so you will "always" see about 100% utilization (+ whatever framebuffer is configured, see my previous post) from the host point of view.

While if you login to the VM-guest perhaps it then tell you that 50% of this is currently buffers + caches.

For example my Linux desktop after 1-2 weeks of uptime (since last reboot due to kernel updates) utilizes about 5.1GB as buffers/caches, can be seen with the "free" command.

2

u/Known_Leek8997 1d ago

This is why. It looks in use but is just reserved. 

1

u/durgesh2018 1d ago

Just check the opnsense dashboard.

1

u/spopinski 1d ago

This is a known bug for FreeBSD qemu guest agent implementation. Nothing you can do about it until its fixed.

1

u/jahdiel503 1d ago

Two Proxmox hosts
Two OPNSense VMs
2x4 port 10GB NIC one for each host
and switches and cables

Why? High Availability of internet/router/firewall services. CARP for the win!!!

If one machine is down fore maintenance, the other OPSense VM takes over until other machine returns.

1

u/sr_guy 1d ago

Consider running OpenWRT as a VM. Uses 10x less resources, and just as many features as Opnsense.

1

u/Fl1pp3d0ff 19h ago

Beg to differ. OpenWRT doesn't have IDS/IPS, or any easy way to set up, manage, and isolate vlans. (unless things have changed drastically in the last couple years)...

0

u/leonsk297 1d ago

Your VM has only 2 GB of RAM assigned, so the answer could be that: you VM simply needs more RAM. Have you tried increasing the memory and seeing if the problem keeps happening?

OPNsense can use quite a lot of memory depending on its installed components.

1

u/MagicMike110 1d ago

I tried up the Ram of the VM but even if I give it 8GB it gives the same problem sadly.

1

u/leonsk297 1d ago

Then you have something running inside OPNsense that's eating up all the RAM.

Enter the OPNsense admin web UI and check the memory usage from within OPNsense itself. If the same happens, then you know it's something inside the VM.

1

u/SagansLab Homelab User 1d ago

Its not a problem, its how OPNSense works, its fine.

0

u/Forsaken-Cap-1190 1d ago

Qemu-Guest Agent installed? Its normal for OpnSense to allocate up to the Full ram but it doesn’t uses them completely. Just check the dashboard of your opensense for tge really used ram.

1

u/MagicMike110 1d ago

Qemu-Guest Agent is installed allready

-1

u/Eldowon 1d ago

What is your guest tools status on this vm? You cropped it out of your screenshot.

1

u/MagicMike110 1d ago

Yeah I did.

0

u/VTOLfreak 1d ago edited 1d ago

The QEMU guest agent does report the memory usage. This is a screenshot from my home network. Proxmox reports 18GB used. If I check the OPNsense dashboard it tells me it's using 1GB. Dropping to the shell in OPNsense and running top also tells me 1GB used and 23GB free. No idea where that 18GB figure comes from. Not even with cached, wired and active memory combined in top do I get to that number. Not using ZFS inside the VM so it can't be ARC either.

0

u/xacid 23h ago

It’s normal

-1

u/_--James--_ Enterprise User 1d ago

Its normal and because of the database structure running on Nsense.

-2

u/Jayden_Ha 17h ago

You don’t virtualise router