Check the disk usage of a virtual machine

a1360550545

New Member
Jan 16, 2024
11
0
1
I am very happy to discuss issues with you here. But I have a problem now. After I created a Linux virtual machine in proxmox, I allocated 40G of space to it, and then I wanted to check its real-time disk usage. Rate, for example, he uses 10G in the system. I want to get this approximate value. When I use du -h to get it in the proxmox shell interface, there are always some errors and inconveniences. I would like to ask if it can be passed. API interface to obtain the disk usage of the specified virtual machine.
 
Hi,

you can get the disk usage inside a guest using the /qemu/{vmid}/agent/get-fsinfo node endpoint.
Though, this will only work if the QEMU guest agent is installed inside the guest!

When I use du -h to get it in the proxmox shell interface, there are always some errors and inconveniences.
Please elaborate. If there really are errors, we'd like to know!

Hope this helps!
 
Hi,

you can get the disk usage inside a guest using the /qemu/{vmid}/agent/get-fsinfo node endpoint.
Though, this will only work if the QEMU guest agent is installed inside the guest!


Please elaborate. If there really are errors, we'd like to know!

Hope this helps!
Thank you very much for your answer. When I executed the command, I got some disk information, but it did not The specific disk usage in the virtual machine.
1706233695892.png
If I use du -h to check the disk usage of the virtual machine, the value obtained is not accurate. I find that it will be greater than the actual disk usage of the virtual machine.
 
Last edited:
Normally the output should also contain keys such as total-bytes and used-bytes, but I do not see them in your screenshot. (Also for the future: Please post something like that in code tags, not as screenshot - it will be much more readable!)

Please provide the output of pveversion -v to help investigate this further.
Also, what OS installed inside the VM? What version of the QEMU guest agent is installed inside the VM?

If I use du -h to check the disk usage of the virtual machine, the value obtained is not accurate. I find that it will be greater than the actual disk usage of the virtual machine.
Please eloborate. What's the "actual disk usage" in your case, i.e. how did you obtain that value?
 
okey. When I use pversion -v the output is as follows
Code:
proxmox-ve: 8.0.1 (running kernel: 6.2.16-3-pve)
pve-manager: 8.0.3 (running version: 8.0.3/bbf3993334bfa916)
pve-kernel-6.2: 8.0.2
pve-kernel-6.2.16-3-pve: 6.2.16-3
ceph-fuse: 17.2.6-pve1+3
corosync: 3.1.7-pve3
criu: 3.17.1-2
glusterfs-client: 10.3-5
ifupdown2: 3.2.0-1+pmx2
ksm-control-daemon: 1.4-1
libjs-extjs: 7.0.0-3
libknet1: 1.25-pve1
libproxmox-acme-perl: 1.4.6
libproxmox-backup-qemu0: 1.4.0
libproxmox-rs-perl: 0.3.0
libpve-access-control: 8.0.3
libpve-apiclient-perl: 3.3.1
libpve-common-perl: 8.0.5
libpve-guest-common-perl: 5.0.3
libpve-http-server-perl: 5.0.3
libpve-rs-perl: 0.8.3
libpve-storage-perl: 8.0.1
libspice-server1: 0.15.1-1
lvm2: 2.03.16-2
lxc-pve: 5.0.2-4
lxcfs: 5.0.3-pve3
novnc-pve: 1.4.0-2
proxmox-backup-client: 2.99.0-1
proxmox-backup-file-restore: 2.99.0-1
proxmox-kernel-helper: 8.0.2
proxmox-mail-forward: 0.1.1-1
proxmox-mini-journalreader: 1.4.0
proxmox-widget-toolkit: 4.0.5
pve-cluster: 8.0.1
pve-container: 5.0.3
pve-docs: 8.0.3
pve-edk2-firmware: 3.20230228-4
pve-firewall: 5.0.2
pve-firmware: 3.7-1
pve-ha-manager: 4.0.2
pve-i18n: 3.0.4
pve-qemu-kvm: 8.0.2-3
pve-xtermjs: 4.16.0-3
qemu-server: 8.0.6
smartmontools: 7.3-pve1
spiceterm: 3.3.0
swtpm: 0.8.0+pve1
vncterm: 1.8.0
zfsutils-linux: 2.1.12-pve1

Code:
root@pve-30-34:~# curl -k https://192.168.30.34:8006/api2/json/nodes/pve-30-34/qemu/104/agent/get-fsinfo -H 'Authorization: PVEAPIToken=root@pam!test=ea9570db-44d4-4016-974c-b239312557d8'
{"data":{"result":[{"name":"sda1","mountpoint":"/boot","disk":[{"pci-controller":{"domain":0,"bus":6,"slot":5,"function":0},"bus":0,"serial":"0QEMU_QEMU_HARDDISK_drive-scsi0","target":0,"bus-type":"scsi","dev":"/dev/sda1","unit":0}],"type":"xfs"},{"disk":[{"serial":"0QEMU_QEMU_HARDDISK_drive-scsi0","target":0,"bus":0,"pci-controller":{"slot":5,"function":0,"bus":6,"domain":0},"bus-type":"scsi","unit":0,"dev":"/dev/sda2"}],"mountpoint":"/","name":"dm-0","type":"xfs"}]}}root@pve-30-34:~#

VM:centos 7
qemu version: qemu-guest-agent-2.12.0-3.el7.x86_64
 

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!