[SOLVED] Automatic Hot/Cold Storage for VMs

jakob_ledermann

New Member
Dec 8, 2025
2
2
1
Our VMs are only used for a few days at a time and then they won't be in use for quite a while.
When they are in use the VMs require fast Storage to be usable, so I tried to use the hookscripts `pre-start` and `post-stop` event to move the disk of the VM from the slow but cheap Networkstorage to the faster SSD on the host and back again.

Unfortunately this does not work properly as the `qm disk move` command fails with a lock timeout.
For the `post-stop` event I already found https://forum.proxmox.com/threads/h...hutdown-from-the-vm-itself.72802/#post-822654 and simliar and am trying to use nohup and background execution at the moment. This does not help for `pre-start`for now.

The version in use is a recent Proxmox VE 9.1.

Did someone successfully implement such a use case?
Has someone different ideas how I could implement this use case?
 
It looks like I managed to implement this successfully with the following hookscript

Bash:
#!/bin/bash
if [ "$2" == "pre-start" ]
then
    echo "Move the disk from NAS to SSD"
    nohup /usr/sbin/qm disk move "$1" sata0 local-zfs --delete true &>/tmp/move-disk-start-$1.log &
    if [ $? == 255 ]
    then
        echo "Disk is already on SSD"
    elif [ $? == 1 ]
    then
        echo "Job has been scheduled"
        exit 0
    else
        echo "Unknown error moving the file to SSD: $?"
        exit 1
    fi
elif [ "$2" == "post-stop" ]
then
    echo "Start moving the disk back to the NAS"
    nohup /usr/sbin/qm disk move "$1" sata0 NAS --delete true --format qcow2 &>/tmp/move-disk-stop-$1.log &
fi

The test VM takes about 10 minutes to start, as the disk is moved to the local-zfs storage but afterwards it is fast to use the Software in the VM.