Get current disk size of LXC via API

jsabater

Member
Oct 25, 2021
109
11
23
48
Palma, Mallorca, Spain
Hey everyone!

I am trying to get the current disk size of a LXC with its rootfs on the local pool, ext4-based. Nothing tricky. This is on PVE 7.4. The command I am executing, from the node where the LXC is, is as follows:

Code:
# pvesh get /nodes/proxmox6/lxc/109/config --output-format=json
{"arch":"amd64","cores":2,"digest":"e4703f43c78da6103a56cbfcb9dc2ef40105ffdf","features":"nesting=1","hostname":"guest1","memory":2048,"nameserver":"192.168.0.253 192.168.0.254","net0":"name=eth0,bridge=vmbr4002,firewall=1,hwaddr=76:67:19:8A:52:40,ip=192.168.0.109/24,mtu=1400,type=veth","onboot":0,"ostype":"debian","rootfs":"volume=local:109/vm-109-disk-0.raw,mountoptions=noatime;lazytime","searchdomain":"domain.com","swap":512,"tags":"debian12;local","unprivileged":1}

Which is the same information shown by the equivalent pct command:

Code:
# pct config 109
arch: amd64
cores: 2
features: nesting=1
hostname: guest1
memory: 2048
nameserver: 192.168.0.253 192.168.0.254
net0: name=eth0,bridge=vmbr4002,firewall=1,hwaddr=76:67:19:8A:52:40,ip=192.168.0.109/24,mtu=1400,type=veth
onboot: 0
ostype: debian
rootfs: volume=local:109/vm-109-disk-0.raw,mountoptions=noatime;lazytime
searchdomain: domain.com
swap: 512
tags: debian12;local
unprivileged: 1

According to the PVE API documentation on this endpoint, it should return the disk size. What am I doing wrong? Does it require some extra parametre?

Thanks in advance.
 
Alright, so for some reason this container does not have a size in its configuration file /etc/pve/lxc/192.conf, whereas others do (all those I have checked, which are not all there are).

I will create a script tomorrow to check all the containers, see if this is just some exception. Question is, what could have caused this situation? I can think of updating the mount options via the API, say adding mountoptions=lazytime;noatime without specifying the disk size? Does not make sense, but could be a bug...

Any hints?
 
Okay, so I went through all the LXC in my cluster and only this one did not have a disk size in its configuration file, so I'll consider this a bug that happened for whatever reason. I stopped the container, edited the file manually to add the disk size, run pct fsck 109 and started the container. Problem solved.

And to answer my original question, I was using the correct endpoint.
 
  • Like
Reactions: Kingneutron

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!