Fastest way to move VM disk to CT Volume

Pedulla

Well-Known Member
Aug 1, 2017
58
8
48
Oregon, USA
PVE 7.1-10
I'm moving some VM's to LXC's. They all have large storage disks attached (>4T)
What's the fastest way move the content from the VM's disks to the CT's volume?
 
Yeah, not seeing it. Both the VM disk and the CT Volume are on the same zfspool.
Seems like they are two completely different methods of providing storage.

Maybe I'm not be searching for the right words or something.
 
Well, its not a standard daily operation so there are no readily available solutions that you can just copy-paste.

create new disk and attach it to VM:
pvesm alloc blockbridge 100 vm-100-disk-1 1G qm set 100 --scsihw virtio-scsi-pci --scsi1 blockbridge:vm-100-disk-1

Inside the VM:
lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 2.2G 0 disk ├─sda1 8:1 0 2.1G 0 part / ├─sda14 8:14 0 4M 0 part └─sda15 8:15 0 106M 0 part /boot/efi sdb 8:16 0 1G 0 disk sr0 11:0 1 4M 0 rom mkfs.ext4 /dev/sdb mkdir /mnt/sdb mount /dev/sdb /mnt/sdb echo "hi there from vm" > /mnt/sdb/hi.txt umount /mnt/sdb

back on the host, unmap the disk from vm:
qm unlink 100 --idlist scsi1

rename the disk using storage specific commands:
bb vss update --vss blockbridge:vm-100-disk-1 --label blockbridge:vm-999-disk-2 == Updated vss: blockbridge:vm-999-disk-2 (VSS1862194C40606620)

attach new disk to the container:
pct set 999 --mp2 blockbridge:vm-999-disk-2,mp=/vmdata pct config 999 arch: amd64 hostname: CT999 memory: 512 mp1: blockbridge:vm-999-disk-1,mp=/data,size=1G mp2: blockbridge:vm-999-disk-2,mp=/vmdata,size=1G ostype: ubuntu rootfs: blockbridge:vm-999-disk-0,size=8G swap: 512

PROFIT:
pct start 999 pct exec 999 cat /vmdata/hi.txt hi there from vm


Blockbridge: Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
rename the disk using storage specific commands:
bb vss update --vss blockbridge:vm-100-disk-1 --label blockbridge:vm-999-disk-2 == Updated vss: blockbridge:vm-999-disk-2 (VSS1862194C40606620)
I'm track'n all the way through except for this part.
I've run out of time to work on this today, but I'll keep digg'n.
 
with ZFS you won't get around copying the data.. VMs use zvols, CTs use regular filesystem datasets, these are not compatible. for other 'raw'-type storages you might get away with re-using the volumes, if
- they don't have a partition table, but the volume/disk itself is formatted with a filesystem
- that filesystem is ext4
 
  • Like
Reactions: Pedulla
Well, its not a standard daily operation so there are no readily available solutions that you can just copy-paste.

create new disk and attach it to VM:
pvesm alloc blockbridge 100 vm-100-disk-1 1G
qm set 100 --scsihw virtio-scsi-pci --scsi1 blockbridge:vm-100-disk-1

Inside the VM:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.2G 0 disk
├─sda1 8:1 0 2.1G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi
sdb 8:16 0 1G 0 disk
sr0 11:0 1 4M 0 rom

mkfs.ext4 /dev/sdb
mkdir /mnt/sdb
mount /dev/sdb /mnt/sdb
echo "hi there from vm" > /mnt/sdb/hi.txt
umount /mnt/sdb

back on the host, unmap the disk from vm:
qm unlink 100 --idlist scsi1

rename the disk using storage specific commands:
bb vss update --vss blockbridge:vm-100-disk-1 --label blockbridge:vm-999-disk-2
== Updated vss: blockbridge:vm-999-disk-2 (VSS1862194C40606620)

attach new disk to the container:
pct set 999 --mp2 blockbridge:vm-999-disk-2,mp=/vmdata

pct config 999
arch: amd64
hostname: CT999
memory: 512
mp1: blockbridge:vm-999-disk-1,mp=/data,size=1G
mp2: blockbridge:vm-999-disk-2,mp=/vmdata,size=1G
ostype: ubuntu
rootfs: blockbridge:vm-999-disk-0,size=8G
swap: 512

PROFIT:
pct start 999
pct exec 999 cat /vmdata/hi.txt
hi there from vm


Blockbridge: Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox

thanks for these steps - I just have one issue - Which package contains "bb" command you used here to rename the storage?
 
thanks for these steps - I just have one issue - Which package contains "bb" command you used here to rename the storage?
That command/package is specific to Blockbridge storage. It was used as an example. Your own commands would depend on your storage backend. There are also some limitations as described by @fabian .


Blockbridge: Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: duality
I was trying to move a drive from a vm to a ct container - i got it moved but the ct container won't start now. Guessing this won't work?

run_buffer: 322 Script exited with status 32
lxc_init: 844 Failed to run lxc.hook.pre-start for container "104"
__lxc_start: 2027 Failed to initialize container "104"
TASK ERROR: startup for container '104' failed
 
we'd need the full log to tell for sure - but my guess is the prerequisites I posted above are not met (no partition table, but directly ext4 on the image)
 
Thanks for all the help, i gave up in the end, reverted the disk back to the original vm, created a new disk and just copied over the data. worked out pretty quick in the end.

This was great steps though. I'm saving it for future!
 
Thanks for all the help, i gave up in the end, reverted the disk back to the original vm, created a new disk and just copied over the data. worked out pretty quick in the end.

This was great steps though. I'm saving it for future!
How exactly did you copy the data? The UEFI VM has 2 partitions. What commands did you use?
 

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!