Importing an LVM-based qemu/kvm VM into Proxmox

law

New Member
Oct 4, 2020
2
0
1
Seattle
Hello, I've installed Proxmox onto a system that used to host a KVM/qemu VM in a separate block-device/LVM partition. The partitions are still there, but I don't know how to import the block devices into Proxmox so the VM can be booted. Basically, I think if I can create a new Proxmox-based VM and specify the pre-existing disks, I might get lucky and the VM would "just boot up". I've tried using pvesm to add the LVM partition, then editing the Proxmox qemu-server/<VM-number>.conf file to point to those LVM devices, but it errors out with 'unable to parse lvm volume name' when I try to start the VM. Any thoughts on what I may be doing wrong?

Here's my various versions and system-output:

root@hv03:/home/law# pveversion -v
proxmox-ve: 6.2-2 (running kernel: 5.4.65-1-pve)
pve-manager: 6.2-12 (running version: 6.2-12/b287dd27)
pve-kernel-5.4: 6.2-7
pve-kernel-helper: 6.2-7
pve-kernel-5.4.65-1-pve: 5.4.65-1
pve-kernel-5.4.34-1-pve: 5.4.34-2
ceph-fuse: 12.2.11+dfsg1-2.1+b1
corosync: 3.0.4-pve1
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.16-pve1
libproxmox-acme-perl: 1.0.5
libpve-access-control: 6.1-2
libpve-apiclient-perl: 3.0-3
libpve-common-perl: 6.2-2
libpve-guest-common-perl: 3.1-3
libpve-http-server-perl: 3.0-6
libpve-storage-perl: 6.2-8
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve4
lxc-pve: 4.0.3-1
lxcfs: 4.0.3-pve3
novnc-pve: 1.1.0-1
proxmox-backup-client: 0.9.0-2
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.2-12
pve-cluster: 6.1-8
pve-container: 3.2-2
pve-docs: 6.2-6
pve-edk2-firmware: 2.20200531-1
pve-firewall: 4.1-3
pve-firmware: 3.1-3
pve-ha-manager: 3.1-1
pve-i18n: 2.2-1
pve-qemu-kvm: 5.1.0-2
pve-xtermjs: 4.7.0-2
qemu-server: 6.2-14
smartmontools: 7.1-pve2
spiceterm: 3.1-1
vncterm: 1.6-2
zfsutils-linux: 0.8.4-pve1

root@hv03:/home/law# lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1
├─sda2 vfat C138-D19E
└─sda3 LVM2_member 83jKKp-0prs-h6oZ-X4do-WAcb-jQWc-GBkmJw
├─pve-swap swap f4db51d5-ff1f-46c8-b7fa-01979e8af17f [SWAP]
├─pve-root ext4 78866a2d-25c3-4e47-a9f0-0dbb9cb58e24 10.9G 50% /
├─pve-data_tmeta
│ └─pve-data-tpool
│ ├─pve-data
│ └─pve-vm--100--disk--0
└─pve-data_tdata
└─pve-data-tpool
├─pve-data
└─pve-vm--100--disk--0
sdb
└─sdb1 LVM2_member YlL5xg-OS3K-6wyQ-e6LY-SkR2-WZ2r-W1Usxb
├─volY-storage ext4 194a8d82-1d5e-4d7d-ac10-01a3c5f57000
├─volY-dopefish
├─volY-dopefishvdb LVM2_member w9lKmW-puxU-akfk-NuK0-yQ2T-uNK3-NVM0Kj
│ └─volX-var2 ext4 c42c2299-d2d7-4e5c-a7c2-5a658b960e82
├─volY-repo
├─volY-ci
└─volY-testvm
sr0

root@hv03:/home/law# lvs -a
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data pve twi-aotz-- 52.37g 0.00 1.59
[data_tdata] pve Twi-ao---- 52.37g
[data_tmeta] pve ewi-ao---- 1.00g
[lvol0_pmspare] pve ewi------- 1.00g
root pve -wi-ao---- 24.75g
swap pve -wi-ao---- 8.00g
vm-100-disk-0 pve Vwi-a-tz-- 32.00g data 0.00
var2 volX -wi-a----- 40.00g
ci volY -wi-a----- 80.00g
dopefish volY -wi-a----- 350.00g
dopefishvdb volY -wi-ao---- 150.00g
repo volY -wi-a----- 60.00g
storage volY -wi-a----- 465.66g
testvm volY -wi-a----- 10.00g
root@hv03:/home/law#
root@hv03:/home/law# vgs -a
VG #PV #LV #SN Attr VSize VFree
pve 1 4 0 wz--n- <99.50g <12.38g
volX 1 1 0 wz--n- <150.00g <110.00g
volY 1 6 0 wz--n- <1.82t <746.84g


root@hv03:/home/law# cat /etc/pve/storage.cfg
dir: local
path /var/lib/vz
content iso,vztmpl,backup

lvmthin: local-lvm
thinpool data
vgname pve
content rootdir,images

lvm: volX
vgname volX
content images

lvm: volY
vgname volY

root@hv03:/home/law# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 pve lvm2 a-- <99.50g <12.38g
/dev/sdb1 volY lvm2 a-- <1.82t <746.84g

root@hv03:/home/law# vgs
VG #PV #LV #SN Attr VSize VFree
pve 1 4 0 wz--n- <99.50g <12.38g
volX 1 1 0 wz--n- <150.00g <110.00g
volY 1 6 0 wz--n- <1.82t <746.84g

root@hv03:/home/law# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data pve twi-aotz-- 52.37g 0.00 1.59
root pve -wi-ao---- 24.75g
swap pve -wi-ao---- 8.00g
vm-100-disk-0 pve Vwi-a-tz-- 32.00g data 0.00
var2 volX -wi-a----- 40.00g
dopefish volY -wi-a----- 350.00g
dopefishvdb volY -wi-ao---- 150.00g

cat /etc/pve/nodes/hv03/qemu-server/100.conf
bootdisk: scsi0
cores: 1
ide2: none,media=cdrom
memory: 4096
name: dopefish
net0: virtio=CA:0E:1E:ED:59:C3,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: volY:dopefish,size=350G
scsihw: virtio-scsi-pci
smbios1: uuid=3bd508e5-7537-4a6d-844c-e1e5d16b4dfb
sockets: 1
vmgenid: 3b807667-6f62-4979-acb1-2b5da7bf5996


The only LVs I care about in the above output are /dev/mapper/volY-dopefish and /dev/mapper/volY-dopefishvdb. I believe if I can get those imported into Proxmox and properly defined in a VM, I should be good to go.
 
The only LVs I care about in the above output are /dev/mapper/volY-dopefish and /dev/mapper/volY-dopefishvdb.
Proxmox expects the disk names to follow a certain naming convention. If the disks don't match this it won't work according to my experience.
I am convinced that is the reason why it fails.
I am not 100% sure about the name but you should easily be able to find out by just adding a new disk.
Rename the existing lvm volumes to match the expected format and I guess you are good to go.
 
Thanks so much for the quick reply! What is the expected naming convention, and would using 'lvrename', 'vgrename', etc, be the way to do it, or is there a proxmox-centric command I should be using instead?
 
This should be the format:
local-lvm:vm-101-disk-0
Local-lvm in this case is the proxmox storage name
I would go with lvrename.
HTH
 
If renaming does not work, you can also dd the logical volume to a regular file

(Please check before copying)
Code:
dd if=/dev/volY/dopefish of=image.raw
and then use the importdisk command of Proxmox VE
Code:
qm importdisk 100 image.raw local-lvm
which handles all the naming.
 

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!