kvm virtual machine usage
I have successfully installed KVM virtual machine for a very long time, but I did not do some actual jobs on it yet.
Today I am started to do some developing jobs towards Hadoop eco-system, which needs virtual machines for a better and clean workspace.
Operate according to this doc, which is already detailed to fully create a KVM machine. I rewrite the build-vm script for creating VM.
During the installation, I encountered some problems. I just wanna share them online.
--dest is the parameter that VM file will be stored, you need to create the folder name yourself, or KVM will have error stack at the final stage! killing time.
If you found it rather slow to initially create a VM, this might caused by the slow network between you and source provider, in my experiment, I use 163 as source provider, be aware of this connection speed between you and source server.
After fetching bin files from source server, maybe it will have a error that shows
Could not found libvirt, whenever this happens, please startup
sudo service libvirt start
After a around 15 mins, the automatical installation procedure already finished and it will deploy to the folder that you specified in
It also very simple and easy to clone a VM rather than recreate a VM from network again!
For more details, please refer to clone
> virt-clone --connect=qemu:///system -o oldVM -n newVM -f /home/rugal/VM/new/NewVM.gcow2
step into VM
Now its time to startup our VM, how exciting!
start to startup VM named
> virsh --connect qemu:///system start master
After installation, the first thing you might to do is use SSH to connect into VM, but actually you do not know about the DHCP allocated IP adress, here I found a method to get IP for your new created VM.
virsh command to find out MAC address of your VM.
Then use ARP scan to determine the allocated IP.
Now just try on this with
Wow it works!
It also very easy to do the reverse action to shutdown VM, just as command below:
> virsh --connect qemu:///system shutdown master
I wrote a script to delete a VM in one command, you will find it rather easy!