How to use new hookscript feature?


Well-Known Member
May 21, 2016

I just noticed, that hookscripts have been implemented in the newest version of Proxmox.
Unfortunately I couldn't find any documentation about it.
Thanks, looks like it's not possible to set one in the UI?
Would be aswesome, if I could add a hook script when cloning a template.

Edit: I think I missunderstood something, they won't be executed in the VM, right?
I was looking for a way, to run commands via Cloudinit after the VM has booted.
Heads up to anyone who comes across this thread, the following is all of the documentation of hook scripts and how to attach to vm's.
10:10, attaching to vm's

You can add a hook script to VMs with the config property hookscript.
# qm set 100 --hookscript local:snippets/
It will be called during various phases of the guests lifetime. For an example and documentation see the example script under /usr/share/pve-docs/examples/

16.8, hookscripts
You can specify a hook script with option --script. This script is called at various phases of the backup process, with parameters accordingly set. You can find an example in the documentation directory (

This is pretty sparse if you ask me.. Especially since I've seen multiple references from mod's to it.
  • Like
Reactions: copec
For anyone else coming across this thread. Here are the commands I used to setup a hookscript for a VM.

#snippets folder didn't exist so I created it
mkdir /var/lib/vz/snippets

#Copied the template to the folder
cp /usr/share/pve-docs/examples/ /var/lib/vz/snippets/

#modified the perl script with the applicable commands
nano /var/lib/vz/snippets/

# Made it executable
chmod +x /var/lib/vz/snippets/

#Set it to the applicable VM
qm set 102 --hookscript local:snippets/
Can I use multiple hookscripts simultaneously?

(One is a bash shell script for GPU passhtrough, the other is written in Perl, for virtio-fs.)
Last edited:


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!