To manage multiple OS, you might have faced the need of Virtual Machines setup. If you are unaware of virtualization you can find more information here. Build Virtual OS using KVM:These instructions are followed on Ubuntu 12.04 LTS and debian based OS. So, lets follow the below instructions and command step by step to create your Virtual Machines. First of all check for CPU supports hardware virtualization. root@rtcamp1~# egrep '(vmx|svm)' --color=always /proc/cpuinfo Output of this command should display something like this: flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflushmmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl extd_apicidpni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch lbrv flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflushmmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl extd_apicidpni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch lbrv or If nothing , then you must stop from here. Now we are going to install kvm and vmbuilder root@rtcamp1~# apt-get update root@rtcamp1~# apt-get install kvm ubuntu-virt-server python-vm-builder kvm-ipxe After that check if kvm has been successfully installed or not root@rtcamp1~# virsh -c qemu:///system list Output should display something like this: root@rtcamp1:~# virsh -c qemu:///system list Id Name State ---------------------------------- If it is showing any error then something is going wrong. root@rtcamp1~# kvm-ok INFO: /dev/kvm exists KVM acceleration can be used (Output should look like this otherwise you would need to enable virtual support from your BIOS settings) We need network bridge on our server . root@rtcamp1~# apt-get install bridge-utils Configure network interface for bridge. root@rtcamp1~# vi /etc/network/interface modify it as follows. auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 192.168.0.1 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 dns-nameservers 8.8.8.8 8.8.4.4 bridge_ports eth0 Restart network service to activate bridge. Reboot the system Now Create VM Example command. root@rtcamp1~# mkdir virtualmachines root@rtcamp1~# cd virtualmachines root@rtcamp1~# vmbuilder kvm ubuntu --suite=precise --flavour=server -m 1024 --rootsize '4096' --swapsize '1024' --kernel-flavour 'generic' --hostname 'ubuntu' --mirror 'http://archive.ubuntu.com/ubuntu' --components 'main,universe' --addpkg 'openssh-server' --name 'rtvm' --user 'rtvm1' --pass 'rtvm123' --ip '192.168.0.124' --mask '255.255.255.0' --net '192.168.0.0' --bcast '192.168.0.255' --gw '192.168.0.1' --dns '8.8.8.8' --bridge 'br0' --libvirt 'qemu:///system' Note: The IP's and gateways used above are of my own LAN, you shall change it as per your own configuration. In this command builder will install openssh-server and vim root@rtcamp1~# ls -l You can find ubuntu-kvm folder root@rtcamp1~# ls -l /etc/libvirt/qemu/ You can find ubuntu.xml created Check with the virsh ( Virtual Shell) root@rtcamp1~# virsh --connect qemu:///system It will drop you in virsh prompt like this – virsh # virsh # list It will show you the running virtual machines list virsh # list --all It will show you all the virtual machines list virsh # list --all Id Name State ---------------------------------- - ubuntu shut off Now start the virtual machine virsh # start ubuntu ( The syntax is - " Now ssh the virtual machine and enjoy…!! -- This Post Create Virtual Machine/OS on Ubuntu 12.04 with KVM is Published on Devils Workshop . | |||
| |||
| |||
|
Friday, 13 July 2012
Create Virtual Machine/OS on Ubuntu 12.04 with KVM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment