Files
Proxmox/volumes/migrate-storage.md

63 lines
2.0 KiB
Markdown

# Migrate VM or LXC from one volume to another
If you messed up and placed your VM or LXC on the wrong storage type, this will help for migrating to the correct storage.
---
## LXC volume migration
LXC migration must be performed on a **stopped** LXC.
For the sake of this example, we are using LXC vmid 205.
Find the available storage name you want to migrate to first:
```
pvesm status
```
Verify the name of the current volume the LXC is contained on:
```
pct config 205 | grep rootfs
````
The output of my available volumes:
```
root@pve:~# pvesm status
Name Type Status Total Used Available %
images dir active 121203372 93525632 21474812 77.16%
iso dir active 40195344 20347016 17774320 50.62%
local dir active 40195344 20347016 17774320 50.62%
local-lvm lvmthin active 55832576 0 55832576 0.00%
nvme lvmthin active 3873329152 1028756222 2844572929 26.56%
pi2 cifs active 13563452384 1357229972 12206222412 10.01%
smb cifs active 6188571648 860594176 5327977472 13.91%
```
Once you verify the lvmthin volume, in this case `nvme`, begin the migration:
```
pct shutdown 205
pct move-volume 205 rootfs nvme
pct start 205
```
1. Shutdown the container
2. Move the container volume to the new lvmthin storage device
3. Start the container
**Notes:** The old storage device will still be connected to the LXC, labeled as `unused disk 0` and will need to be manually deleted to recover the storage space.
---
## VM volume migration
VM migration is easier and can happen **live**.
Example:
- `vmid 800` - VM ID number
- `storage scsi0` - VM storage device (hardware tab, hard disk # ID)
- `nvme` - target storage
- `--delete 1` - delete source volume
```
qm move-disk 800 scsi0 nvme --delete 1
```