# Move VM to new datastore

Note: Make sure there is enough free space on the destination datastore.

## Move using the GUI

Find the VM you want to move, then go to the Hardware tab. Mark each drive and under `Disk Action` select `Move Storage`. Follow the 

## Move using the CLI

### List available datastore

- Get VMID from VM list: `qm list`
- Get all datastores: `pvesm status`

### Example bash script:
```
#!/bin/bash

# Get VMID from VM list: qm list
# Get all list of datastores: pvesm status

myvmid=$1
datastore=$2

echo ***
echo Moving $myvmid to $datastore
echo

for vmid in $myvmid; do
  for disk in $(qm config $vmid | grep vm-$vmid-disk | cut -d: -f1); do
    echo Moving: vm-$vmid-disk
    qm move-disk $vmid $disk $datastore --delete
  done
done

```

