Use existing zvol for VM

Mar 8, 2016
66
5
73
Hello!

I am migrating my VM setup from OpenIndiana to Proxmox. I was able to import my zpool into Proxmox, and able to create a new VM that I wanted to rebuild. I have added ZFS storage in Proxmox and when I created the new VM it created it as a zvol, which is how I did things on OpenIndiana also.

My zpool has existing zvols for virtual machines that I'd love to be able to just rebuild the KVM configuration and have Proxmox run those existing zvols as the disk.

Here are some datasets, zfs list, vm-100-disk-1 obviously one created by Proxmox :

Code:
reds/proxmox                         282M  4.33T    96K  /reds/proxmox
reds/proxmox/vm-100-disk-1           282M  4.33T   282M  -
reds/vm-central                      124G  4.33T   660K  /reds/vm-central
reds/vm-central/huginn              21.1G  4.33T   144K  /reds/vm-central/huginn
reds/vm-central/huginn/disk0        21.1G  4.34T  8.67G  -
reds/vm-central/observium           12.7G  4.33T   144K  /reds/vm-central/observium
reds/vm-central/observium/disk0     12.7G  4.34T  4.40G  -
reds/vm-central/ourblogs            12.7G  4.33T   144K  /reds/vm-central/ourblogs
reds/vm-central/ourblogs/disk0      12.7G  4.33T  12.7G  -

Is there a way I can point Proxmox to those zvols? Or, if not, maybe I could create a similar sized new vm disk and zfs send | zfs recv it, clearing the blank one?

I don't mind messing with a config file at the terminal, but I haven't dug around to find those yet.

Thanks
 
Just create a new file <id>.conf (copy from an already created one and change it) in your /etc/pve/qemu-server folder. For compliance, I'd suggest renaming your zfs volumes according to the "official" schema. I think that'll work.
 
Yes, renaming, zfs send/receive as well as zfs clone followed by zfs promote should all work. It's always recommended to have backups before doing such potentially destructive operations though.
 
  • Like
Reactions: Kingneutron
Yes, I hadn't read fabian's comment before giving it a try. Simply changing the config file to point to my old disk didn't work, probably due to the path not being in Proxmox's storage tree yet.

I decided the best way was to recreate the VM using standard Proxmox routines, then snapshot my disk and ZFS Send it to overwrite the newly created (blank, not booted yet) disk.

So, like this:
Code:
root# zfs snapshot reds/vm-central/xubuntu/disk0@migration
root# zfs send reds/vm-central/xubuntu/disk0@migration | zfs recv -F reds/proxmox/vm-101-disk-1

Need the -F in recv to force it to overwrite the existing file system. Be very careful with the disk names though!!!
 
  • Like
Reactions: disgustipated