Migrate local disk between storages (live)

Snowmanko

Member
Apr 8, 2021
6
0
6
37
Hi fellow proxmoxers,

I just want to ask if it is possible to move VM disks from one storage to another on local node.
I have 2 storages, vmstorage and vmstorage2. I want to move VMs disks from vmstorage to vmstorage2 (all done localy on one node) while VM is running.

Whats the right qm command?

Thanks.
BR!
 
Don't know the am command but it's possible to move disk from the hardware vm view on the web UI directly. Select disk and a move button appears on the tob.
 
the right command is 'qm move_disk' see 'man qm' for details
 
  • Like
Reactions: fireon
Code:
qm move_disk <vmid> <disk> <storage> [OPTIONS]

Move volume to different storage.

<vmid>: <integer> (1 - N)The (unique) ID of the VM.
<disk>: <efidisk0 | ide0 | ide1 | ide2 | ide3 | sata0 | sata1 | sata2 | sata3 | sata4 | sata5 | scsi0 | scsi1 | scsi10 | scsi11 | scsi12 | scsi13 | scsi14 | scsi15 | scsi16 | scsi17 | scsi18 | scsi19 | scsi2 | scsi20 | scsi21 | scsi22 | scsi23 | scsi24 | scsi25 | scsi26 | scsi27 | scsi28 | scsi29 | scsi3 | scsi30 | scsi4 | scsi5 | scsi6 | scsi7 | scsi8 | scsi9 | virtio0 | virtio1 | virtio10 | virtio11 | virtio12 | virtio13 | virtio14 | virtio15 | virtio2 | virtio3 | virtio4 | virtio5 | virtio6 | virtio7 | virtio8 | virtio9>
The disk you want to move.

this looks correct. Thanks.

Is there also command how to list all disks of VM with command? So I can make script that will move all disks of certain VMs to new storage?
 
Last edited:
'qm config ID' will show you the whole config, but you'd have to parse it yourself. alternatively with 'pvesh' you can get json output (makes it easier to parse probably):
'pvesh get /nodes/NODENAME/qemu/ID/config --output-format json'
 
It works well, but when I am trying to move cloud-init image it throws an Error, but disk seems to get copied.

# qm move_disk 101 ide0 vmstorage2 --delete
create full clone of drive ide0 (vmstorage:101/vm-101-cloudinit.qcow2)
Formatting '/opt/vmstorage2/images/101/vm-101-cloudinit.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=metadata compression_type=zlib size=4194304 lazy_refcounts=off refcount_bits=16
Use of uninitialized value $completion in string eq at /usr/share/perl5/PVE/QemuServer.pm line 7246.

Is this a bug?
 
'qm config ID' will show you the whole config, but you'd have to parse it yourself. alternatively with 'pvesh' you can get json output (makes it easier to parse probably):
'pvesh get /nodes/NODENAME/qemu/ID/config --output-format json'
Is their a way to do the disk move with pvesh? I dont want to jump around diffrent nodes in the cluster. Have over 40 VM's on various hosts.

Nevermind figured it out

pvesh create /nodes/server/qemu/712/move_disk --disk ide0 --storage proxvm delete
 
Last edited: