Categories
SysOps

How to install Guest Agent inside Proxmox virtual machine

Install Guest Agent inside Proxmox virtual machine.

List virtual machines.

proxmox$ qm list
      VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID       
       100 ubuntu-jammy-jellyfish stopped    2048              20.00 0         
       102 debian-bullseye        stopped    2048              20.00 0         
      3001 consul-1               running    2048              20.00 397130    
      3002 consul-2               running    2048              20.00 396537    
      3003 consul-3               running    2048              20.00 396585 

Get VM configuration.

proxmox$ qm config 3003
boot: order=scsi0;ide2;net0
cores: 2
ide2: local:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom,size=1432338K
memory: 2048
meta: creation-qemu=6.2.0,ctime=1656270900
name: consul-3
net0: virtio=2E:AE:A1:14:0E:BF,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-lvm:vm-3003-disk-0,cache=writethrough,iothread=1,replicate=0,size=20G,ssd=1
scsihw: virtio-scsi-single
smbios1: uuid=8580553f-388e-42b1-9510-eca6e809be34
sockets: 1
vga: std
vmgenid: 79703a1a-fb97-4f86-ac69-b5e1f7372c1b

Enable agent.

proxmox$ qm set 3003 --agent 1
update VM 3003: -agent 1

Inspect pending changes.

proxmox$ VMID=3003 && diff <(qm config $VMID --current) <(qm config $VMID)
0a1
> agent: 1

Reboot virtual machine.

proxmox$ qm reboot 3003

Execute any Qemu Guest Agent command to test communication.

proxmox$ qm agent 3003 ping
QEMU guest agent is not running

Install QEMU guest agent inside virtual machine.

milosz@jammy:~$ sudo apt install qemu-guest-agent
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  qemu-guest-agent
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/253 kB of archives.
After this operation, 859 kB of additional disk space will be used.
Selecting previously unselected package qemu-guest-agent.
(Reading database ... 108782 files and directories currently installed.)
Preparing to unpack .../qemu-guest-agent_1%3a6.2+dfsg-2ubuntu6.2_amd64.deb ...
Unpacking qemu-guest-agent (1:6.2+dfsg-2ubuntu6.2) ...
Setting up qemu-guest-agent (1:6.2+dfsg-2ubuntu6.2) ...
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

Inspect service status.

milosz@jammy:~$ systemctl status qemu-guest-agent.service 
○ qemu-guest-agent.service - QEMU Guest Agent
     Loaded: loaded (/lib/systemd/system/qemu-guest-agent.service; static)
     Active: inactive (dead)

Reboot virtual machine.

milosz@jammy:~$ sudo reboot

Inspect service status after reboot.

milosz@jammy:~$ systemctl status qemu-guest-agent.service 
 qemu-guest-agent.service - QEMU Guest Agent
     Loaded: loaded (/lib/systemd/system/qemu-guest-agent.service; static)
     Active: active (running) since Tue 2022-07-12 18:53:18 UTC; 19s ago
   Main PID: 638 (qemu-ga)
      Tasks: 2 (limit: 2241)
     Memory: 1.1M
        CPU: 22ms
     CGroup: /system.slice/qemu-guest-agent.service
             └─638 /usr/sbin/qemu-ga

Jul 12 18:53:18 jammy systemd[1]: Started QEMU Guest Agent.
Jul 12 18:53:25 jammy qemu-ga[638]: info: guest-ping called
Jul 12 18:53:36 jammy qemu-ga[638]: info: guest-ping called

Execute Qemu Guest Agent command to test communication.

proxmox$ qm agent 3003 ping