Moving all disks to new Storage

Younex

Well-Known Member
Jan 30, 2018
93
22
48
44
Hi,

Sometimes i need to move all disk of each VM to new storage in order to maintenance on SAN.

I do this by clicking manually trough each VM and move each disk.

Is there any command to move all existing disks on one storage to another?

Thanks!

Kind Regards
 
Last edited:
There is no single command that moves all disks of a given VM to another storage. You should write a script that utilizes either API or CLI to automate things.
A very back of the napkin example:
Code:
for vmid in 2000 2001;do for disk in $(pvesm list blockbridge1 --vmid $vmid|egrep -v Volid|awk '{print $1}');do echo qm move-disk $vmid $disk blockbridge2;done;done
qm move-disk 2000 blockbridge1:vm-2000-cloudinit blockbridge2
qm move-disk 2000 blockbridge1:vm-2000-disk-0 blockbridge2
qm move-disk 2001 blockbridge1:vm-2001-cloudinit blockbridge2
qm move-disk 2001 blockbridge1:vm-2001-disk-0 blockbridge2


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Kingneutron
Hi,

Sometimes i need to move all disk of each VM to new storage in order to maintenance on SAN.

I do this by clicking manually trough each VM and move each disk.

Is there any command to move all existing disks on one storage to another?

Thanks!

Kind Regards
This could be nice feature to have in GUI. Most our VM have multiple disks and this should help.
 
This could be nice feature to have in GUI. Most our VM have multiple disks and this should help.
Sure, it's nice to have CLI vs GUI parity. But at the same time, it would mean a batch operation to do something that can fail in multiple places. That, in turn, means error recovery from all the edge conditions. GUI users, generally, expect "easy to understand error message". Additionally, in some cases, you may want a rollback of the operation, which is not an easy task.

All of that is for a once-a-year (if that) event that is unlikely to be performed by most users, and those who do need it are likely to have the skills to execute it.
Can you make a business case for it? Sure. But it would need to be more than a "nice feature to have".


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
Very simple script, no error checking: input vm id and target storage name

Bash:
#!/bin/bash

read -p "VM ID: " vm
read -p "Target storage name: " target

echo .
echo "Migrate all disks for VM: $vm to Storage: $target"
echo .
read -p "Are you sure ? | Y: Continue N: Stop " go

if [ "$go" = "y" ] || [ "$go" = "Y" ]
    then
        for disk in $(qm config $vm | grep vm-$vm-disk | grep -v unused | cut -d: -f1); do
        ## --delete deletes the source disk after copy/clone
        qm move-disk $vm $disk $target --delete
        done
    else
    echo "No action taken... bye"
    
    fi
 
But when you have access only using web interface (AD as LDAP), you can do things only in GUI.
 
But when you have access only using web interface (AD as LDAP), you can do things only in GUI.
Shell is accessable within the webinterface: DATACENTER --> nodename --> Shell.

open shell --> typ: nano movedisks.sh --> copy/paste script --> CTRL + X --> confirm with Y and hit Enter --> typ: bash movedisks.sh
 
Shell is accessable within the webinterface: DATACENTER --> nodename --> Shell.

open shell --> typ: nano movedisks.sh --> copy/paste script --> CTRL + X --> confirm with Y and hit Enter --> typ: bash movedisks.sh
No shell for LDAP users. This works only for @pam
 

About

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!