Restore .img file of LVM partition to a new VG?

Hi, so I recently botched broke a XenServer install and wasn’t able to boot correctly. The VG with all the data for the VMs was intact so I backed them all up with dd to an .img file. I tested some of the .img files on kvm and it still worked. I am just unsure how to add them back to XenServer. I thought there would be a way with dd to restore it. I might just be missing something. I’d ideally add the .img files to the new VG on the new XenServer install.

Thanks,
Maxamus456

Just DD the imgs to their new lv partitions

so I would dd if=/path/to/.img of=/dev/xenserver-vg/name-of-new-lvm-partition ?

yep…

Thanks, I wasn’t expecting it to be so simple

It didn’t work
I do
dd if=VG_XenStorage–6a48efa2–2236–d4db–f2ea–1d6366eb1d02-VHD–48ec1deb–1cac–44cc–bd84–3bd04b79994c.img | ssh [email protected] dd of=/dev/VG_XenStorage-e097d89b-02e3-af9e-68ed-1c88f51e9415/VHD-c0c0a5fb-e0d4-4389-bace-b273a35639cb

and get

dd: writing to ‘/dev/VG_XenStorage-e097d89b-02e3-af9e-68ed-1c88f51e9415/VHD-c0c0a5fb-e0d4-4389-bace-b273a35639cb’: No space left on device
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000245029 s, 0.0 kB/s

I’m pretty sure my syntax is right. There is plenty of space on the SSD I am moving everything to. So I don’t know what I have done wrong

Sounds like the target is too small

The .img files are all of 15GB LV partitions. So I tried making some new 15GB LV partitions to dd them back into. That didn’t work. So I tried a 16GB partition and that should have been enough. Most of the .img files are only around 5GB so i know there is some compression going on. But that shouldn’t effect it?

… It might not have occured to me that I should mount the partition before I try to dd… I belive it is working now…

Can’t you create loop devices for this dd images and run from that? Something like losetup --find --show ~/file.img /dev/loop0, then try if LVM would import using loop0? Then you can transfer the data.