KVM: How to Attach guest vm to another kvm VPS
This guide will help you how to attach guest vm to another kvm VPS. This usually used for customer which has broken kvm VPS (exabytes ID) that can’t be booted somehow but the data still there. So we take initiative to create new vm (contact senior) deploy new VM as free and attach broken vm to newly created vm. In this case there are some steps need to be done.
Table of Contents
Check point 1 : Make sure the broken vm & newly created vm under 1 host server
This is very important, because this method can be happen when the vms under 1 host server.
Check point 2 : Make sure the broken vm is turned off
In order the disk to be read in another guest vm, make sure the broken vm is turned off. If it does not turned off, then it can’t be read by another guest vm.
Check point 3 : Remember the broken vm ID
There is a custom script that need to be attached under newly created vm and we need to take a note the broken vm ID.
Question: Where I can found this vm ID? Go to SolusVM > Search the broken vm name > Pay attention for ID section. Example below:

Check point 4 : Create custom script
Please make a custom script as below and adjust the broken vm ID as per needed. Save it somewhere else, ie. notepad.
<disk type='file' device='disk'> <source file='/dev/idssd02/kvm867_img'/> <target dev='hdd' bus='virtio'/> </disk>
Check point 5 : Go to Solusvm > Search for new deployed vm > Go to Custom Config
Copy all the ‘Live Config’ and paste to Enable Custom Config. Don’t forget to tick “Enable Custom Config”

Copy the script from Check point 4 previously and insert into <disk> section right before line <interface type=’bridge’> See example below.

Then Save & Reboot in the same page.
Check point 6 : Mount the Disk
We are good now. After new server booted up, please mount the disk. Check the whole disk by typing :
[root@so ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom vda 253:0 0 40G 0 disk ├─vda1 253:1 0 39G 0 part / └─vda2 253:2 0 1G 0 part [SWAP] vdb 253:16 0 40G 0 disk ├─vdb1 253:17 0 39G 0 part /lama └─vdb2 253:18 0 1G 0 part
The new disk now attached as vdb1. Now we can attach to actual disk. We create new folder first. ie. lama.
$ mkdir /lama $ mount /dev/vdb1 /lama
Done.
Check point 7 : We are done
Everything is done. Make sure you inform cust with correct information.
Please ask senior to sync whmcs information with newly created vm.
Some reference that you might want to take a look :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_administration_guide/sect-virtualization-adding_storage_devices_to_guests-adding_hard_drives_and_other_block_devices_to_a_guest
