[SOLVED] Unable to start VM with Hookscript

sabersoul1217

New Member
Dec 23, 2025
6
0
1
I'm running PVE 9.2.20. In my server is an ARC A330 for my Plex VM running Windows for transcoding. Shutting down or restarting the VM for any reason causes my entire server to hang (including the IPMI if I wait long enough). Searching for an answer led me to this post: https://forum.proxmox.com/threads/i...-pci-not-ready-after-flr-or-bus-reset.130667/

Manually putting these commands in the console (these are the IDs for my GPU and the HD Audio)
Code:
echo > /sys/bus/pci/devices/0000:67:00.0/reset_method
echo > /sys/bus/pci/devices/0000:68:00.0/reset_method
allows me to safely shut down or restart the VM once, then I have to do it again if I need to shut down or reboot the VM again.

I copied the hookscript in that post, modified the IDs to match mine, copied the script to /var/lib/vz/snippets/ via sftp, did a chmod 777 on the file just to cover my bases on permissions, and finally ran qm set 104 --hookscript local:snippets/intel-dGPU-hookscript.sh to set my VM (104) to run the hookscript. Unfortunately, every time I try to start the VM I get this error:
Code:
TASK ERROR: hookscript error for 104 on pre-start: command '/var/lib/vz/snippets/intel-dGPU-hookscript.sh 104 pre-start' failed: open3: exec of /var/lib/vz/snippets/intel-dGPU-hookscript.sh 104 pre-start failed: No such file or directory at /usr/share/perl5/PVE/Cmd.pm line 174.
I copied the Cmd.pm file to my system and looked at line 174 as indicated, but I don't know what I'm really looking at to try and resolve this. Can anyone help me out? Line 174 just says this:

$pid = open3($writer, $reader, $error, @$cmd) || die $!;

I'm happy to include copies of both the hookscript and the Cmd.pm file if it's helpful...
 
Did you create your hook script on Windows (CRLF line endings)? If so, save in unix file format or convert otherwise.

If it's Windows line endings it's trying to run the script with #!/bin/bash\r (which doesn't exist) instead of just #!/bin/bash.
 
Last edited:
did you mark the script as executable?
 
Did you create your hook script on Windows (CRLF line endings)? If so, save in unix file format or convert otherwise.

If it's Windows line endings it's trying to run the script with #!/bin/bash\r (which doesn't exist) instead of just #!/bin/bash.
I just did that in notepad++, no change.
 
is the "shebang" (first line) of the script correct? could you maybe post it?
 
is the "shebang" (first line) of the script correct? could you maybe post it?
You know, I hadn't paid attention to that, but I've never seen anything start a shell script like that before. I'm going to try removing that #!. I simply copy/pasted from that other thread, but I would think that it should just start with /bin/bash. This is the original. I'm going to remove that #! and try again.
Code:
#!/bin/bash
set -e -o errexit -o pipefail -o nounset

# located in /var/lib/vz/snippets/intel-dGPU-hookscript.sh or your 'snippets' location.
# Add to VM via: qm set VMID --hookscript local:snippets/intel-dGPU-hookscript.sh

# Do not modify these variables (set by Proxmox when calling the script)
vmId="$1"
runPhase="$2"
echo "Running $runPhase on VM=$vmId"

case "$runPhase" in
    pre-start)
        # Clear the reset methods before each start of the VM, to prevent the PVE host locking up
        # flr and bus methods dont work and re-appear after reboots.
        # bus method may still be attempted in subseqent VM starts, even if reset_method already cleared.
        echo "VM=$vmId - $runPhase : Clearing Intel dGPU and audio device reset_methods."
        echo > /sys/bus/pci/devices/0000:67:00.0/reset_method
        echo > /sys/bus/pci/devices/0000:68:00.0/reset_method

        # will appear as the following in journalctl:
        #  kernel: vfio-pci 0000:67:00.0: All device reset methods disabled by user
        #  kernel: vfio-pci 0000:68:00.0: All device reset methods disabled by user
    ;;

    post-start)
        # placeholder .
        echo "VM=$vmId - $runPhase : No Action."
      ;;

    pre-stop)
        # placeholder .
        echo "VM=$vmId - $runPhase : No Action."
      ;;
    post-stop)
        # placeholder .
        echo "VM=$vmId - $runPhase : No Action."
      ;;
    *)
      echo "Unknown run phase \"$runPhase\"!"
      ;;
esac
echo "Finished $runPhase on VM=$vmId"
 
Got it! Thank you @fabian and @AlexHK ! It was a combination of both. I removed the #! on Windows and uploaded it back to the server, thinking that Notepad++ was going to remember that I had saved it as a Unix file. It did not. So I opened the file in nano, saved it while toggling the DOS Format off, and my VM started!