When shutting down Proxmox, I found that it would not shut down TrueNAS without me going into the console and doing it manually. I am looking to add a UPS at some stage, and that got me wondering,in the event of a power failure and relying on a battery to shut everything down gracefully, will Proxmox be able to shut down TrueNAS Core? No it would not. This led me to explore QEMU agents and how to integrate a VM with the Proxmox environment.
One problem with TrueNas Core, is that it is not an application running on top of a Linux machine, it is an appliance in and of itself. This means no apt install or anything like that is supported and all alterations are intended to be done through the web interface. But there is no option there to install the agent.
My first round of googling led me to a convoluted way of installing the agent that I was not going to do. Fortunately, someone called “gushmazuko” (https://github.com/gushmazuko/truenas-qemu-guest-agent) has written it up into a bash script which downloads the required kernel, strips the QEMU agent out and installs it. But… it errored out due to an outdated version of the agent being specified. After a bit more googling I found the current version here : https://pkgs.org/download/qemu-guest-agent
Now I had to modify the script to strip out the current version that is actually downloaded.
First, jump into the TrueNAS console via Proxmox, then open a shell:
Download the script:
curl -O https://raw.githubusercontent.com/gushmazuko/truenas-qemu-guest-agent/master/install.sh
Make it executable:
chmod +x install.sh
Then we have to modify it so it looks for the correct version of the agent.
Using vi or nano, open install.sh, and find the line referring to the guest agent package, then modify the version to match the one from pkgs.org mentioned above.
Save the modified install.sh and execute:
./install.sh
This will do its thing, and once complete, Proxmox will be able to shut the VM down gracefully. This can be initiated by the user via the web interface, or in the event of shutting down / rebooting Proxmox, the system will now shut down TrueNAS without intervention.