$ cat proxmox-lxc-containers-show-the-host-s-uptime-and-ram-wrong-.md
Proxmox LXC Containers Show the Host's Uptime and RAM Wrong: What lxcfs Actually Does
You give a container 2 GB of RAM and 2 cores. You open a shell inside it, run free -h, and see 2 GB total. Good. Then you install a monitoring agent or a Java app, and it behaves as if the machine has 64 GB and 16 cores. Sometimes free shows the host’s numbers too. Same container, different answers depending on which tool asks.
The difference comes down to lxcfs, a small FUSE filesystem that Proxmox runs on the host. When it works, you never think about it. When it doesn’t, you get odd memory readings and apps that size themselves wrong.
Why containers need a translation layer
An LXC container shares the host kernel. Files like /proc/meminfo, /proc/cpuinfo, /proc/uptime and /proc/stat are generated by that kernel and describe the whole machine. The memory limit you set lives in a cgroup, which most userland tools never read.
lxcfs sits in between. It mounts replacement files under /var/lib/lxcfs on the host, and the container runtime bind-mounts them over the matching /proc and /sys/devices/system/cpu paths inside the guest. Read /proc/meminfo in the container and you get numbers computed from that container’s cgroup limits and usage.
Files it covers include:
/proc/meminfo/proc/cpuinfo/proc/stat/proc/uptime/proc/diskstats/proc/swaps/sys/devices/system/cpu/online
Anything not on that list still shows host values. /proc/loadavg has been a classic offender. Load average inside a container may reflect the whole host depending on version and setup, so a quiet container can look busy because a neighbor is thrashing.
Check that it is running
On the Proxmox host:
systemctl status lxcfs
mount | grep lxcfs
ls /var/lib/lxcfs/proc
You should see an active service and a populated proc directory. If the service is dead, containers that start while it is down come up with the raw host files. That is the nasty part. Nothing errors. The container just lies quietly.
Then compare from inside a container:
grep MemTotal /proc/meminfo
cat /proc/uptime
nproc
MemTotal should match the limit in the container config. uptime should match the container’s age, not the host’s. If MemTotal equals the host’s RAM, check whether lxcfs was running when that container last started.
Restarting lxcfs is not free
The tempting fix is systemctl restart lxcfs. Be careful. Running containers hold bind mounts to the old FUSE instance. After a plain restart, those mounts can go stale, and reading /proc/meminfo inside the guest fails with “Transport endpoint is not connected” or returns nothing. Apps that parse those files can crash or hang.
Recent Proxmox releases handle package upgrades of lxcfs more gracefully, using reload semantics so mounts survive. A manual restart does not get that treatment. The safe order is:
- Schedule a window.
- Restart lxcfs.
- Stop and start each affected container with
pct stopthenpct start(apct rebootcan reuse the mount namespace in some cases, so a full stop/start is the safer habit).
If you only care about one container that came up while lxcfs was down, a stop/start of that container alone is enough.
Where it bites in practice
JVM-based apps and anything that reads /proc/meminfo or nproc to size thread pools and caches are the usual victims. Modern runtimes also read cgroup limits directly, so they often get it right regardless. Older or unusual ones do not. If a service allocates memory like it owns the host, check the numbers inside the container before blaming the app.
Node exporter and similar agents running inside a container will report lxcfs-translated values for memory, which is what you want per guest. But the host-side view in Proxmox comes from cgroup accounting, not from lxcfs. If the two disagree by a few hundred MB, that is usually page cache being counted differently, not a fault.
Docker inside an LXC adds another wrinkle. Docker’s own tools read the container’s /proc, so they inherit whatever lxcfs shows. docker stats limits per Docker container are a separate layer on top.
Cores are a limit, not a mask
Setting cores: 2 on a Proxmox LXC does not pin the guest to two CPUs by default. It sets a CPU weight and quota behavior depending on configuration, and lxcfs reports a CPU count derived from it. If you set cpulimit, the quota caps total CPU time, and nproc may still show more logical CPUs than the quota allows. Software that spawns one worker per visible CPU can oversubscribe and then get throttled. Setting worker counts explicitly in the app config is more predictable than trusting autodetection.
A quick sanity check after host reboots
After a reboot, run this from the host for one container:
pct exec 101 -- grep MemTotal /proc/meminfo
Compare against pct config 101 | grep memory. If they match, lxcfs was up before the guest. If they don’t, fix your boot ordering so the lxcfs service starts first, and bounce that guest. I keep this check as the last line of my post-reboot script, because the failure is silent and the only symptom is an app making bad decisions three weeks later.