[SOLVED] Create Ceph block device from RAW image

kwinz

Active Member
Apr 18, 2020
40
14
28
36
Hi,

I apologize, is this probably a really trivial question for most here.
I am trying to convert a physicial server to a VM.
So I have booted off a live cd and created a RAW image of the pysical server's SSD (with dd).
That image file is now on an ext4 formatted USB drive.

How do I import that RAW image file into my ceph pool as a new RDB block drive so I can use it as a boot drive for a new virtual machine?

Basically this: https://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE but I want to store the vm's drive on CEPH.

I want to do the opposite of this: https://forum.proxmox.com/threads/export-ceph-image-to-gzip.75915/post-337899
Instead of exporting an RBD block device to a RAW image file with rbd export, I want to create an RBD block device from a RAW image file and then use that for a new VM.

So should I use rbd import and/or qm importdisk?
 
Last edited:
The Proxmox VE way would be to create the VM first, remove the automatically created drive if you do not need it and then use qm importdisk <vmid> /path/to/raw/file <storage name>. This will import it and create an Unused drive in the VM config which you then can attach. Don't forget to edit the boot order of the VM in the VM options.
 
  • Like
Reactions: kwinz
Thanks for your reply!

I solved it in a different way, before you posted it. Here is the different way for completeness:

Code:
#import as RBD block device into ceph pool "cephpool1"
root@pve4:~# rbd import --dest-pool cephpool1 /mnt/usbdrive/sda.img dserv
Importing image: 41% complete...^[[B
Importing image: 100% complete...done.

#check if md5 hash I made of the source drive earlier is still the same
root@pve4:~# rbd map --image cephpool1/dserv
/dev/rbd0
root@pve4:~# md5sum /dev/rbd0
d381c5e217e5e5d3267cb6cc15c1741e  /dev/rbd0
root@pve4:~# rbd unmap /dev/rbd0

Now I wasn't able to add this as storage to any VM. So I tricked a bit. I created a new VM that happend to be "vm-109".

Code:
#Deleted its disk
root@pve3:/etc/pve# rbd remove cephpool1/vm-109-disk-0

#Renamed my imported RBD to replace the deleted storage
root@pve3:/etc/pve# rbd rename  cephpool1/dserv cephpool1/vm-109-disk-0

#And finally I had qm update the storage size to the new storage size in "qemu-server/109.conf"
root@pve3:/etc/pve# qm rescan --vmid 109
rescan volumes...
VM 109 (virtio0): size of disk 'images1:vm-109-disk-0' updated from 238G to 250059096K
 
Last edited:

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!