INSTALLATION OF KVM ON UBUNTU BY CLI MODE
Run
Command for check KVM
raj@raj:~#lsmod
|grp kvm
kvm-ok
Installing
KVM
KVM
only works if your CPU has hardware virtualization support – either
Intel VT-x or AMD-V. To determine whether your CPU includes these
features, run the following command:
raj@raj:~#
egrep -c ‘(svm|vmx)’ /proc/cpuinfo
flags  :
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni
dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave
lahf_lm dtherm tpr_shadow vnmi flexpriority
raj@raj:~#
 apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager
qemu-system virtnist virt-manager
Afterwards
we must add the user as which we're currently logged in (root) to the
group libvirtd: 
raj@raj:~#adduser
raj
raj@raj:~#adduser
raj kvm
raj@raj:~#adduser
raj libvirtd
To
check if KVM has successfully been installed, run
raj@raj:~#virsh --connect qemu:///system list Id Name State ---------------------------------------------------- 3 raj running Creating Bridge Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network. raj@raj:~#vim /etc/network/interfacesWe edit the file, so it gets the following content:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto br0 iface br0 inet static address 192.168.3.10 netmask 255.255.255.0 network 192.168.3.0 broadcast 192.168.3.255 gateway 192.168.3.1 bridge_ports eth0 bridge_stp off bridge_maxwait 5 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 192.168.0.4
raj@raj:~#/etc/init.d/networking
restart
raj@raj:~#brctl
show 
bridge
name bridge id  STP enabled interfaces 
br0  8000.00270e31e030 no  eth0
virbr0  8000.fe54000fee09 
         yes  vnet0 
raj@raj:~#qemu-img
create -f qcow2 /ubuntu/raj.qcow2  +10G 
OR
raj@raj:~#dd
if=/dev/zero of=/ubuntu/raj.img bs=512M count=10
Install
from Network 
raj@raj:~#virt-install
-n raj -r 1024  --vcpus=1 --cpu host --os-type=linux 
--os-variant=ubuntuprecise --disk path=/ubuntu/raj.qcow2 
--accelerate --graphics none 
--bridge=virbr0
-l
http://de.archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/
-x 'console=tty0 console=ttyS0,1152' 
OR
If
you have any iso:-
raj@raj:~#virt-install
-n raj -r 1024  --vcpus=1 --cpu host --os-type=linux 
--os-variant=ubuntuprecise --disk path=/ubuntu/raj.qcow2 
--accelerate --graphics none --bridge=virbr0 -l /path of iso -x
'console=tty0 console=ttyS0,1152'
-n
specify the name of Virtual Machine
-r
specify the amount of memories of Virtual Machine
--vcpus=specify
the virtual CPUs
--os-type=specify
types of GuestOS 
--network=specify
network types of Virtual Machine 
--nographics=nographics
-l=specify
location of installation where from
 --disk
path=specify of storage of vm
Manage VMs with virsh
To
stop a VM and destroy a guest domain (Shutdown)
raj@raj:~#virsh
destroy raj
To
remove the Vm 
raj@raj:~#virsh
undefine raj
To
suspend a VM
raj@raj:~#virsh
 suspend raj
To
autostart a VM upon host booting
raj@raj:~#virsh
autostart raj
To
get domain information of a VM
raj@raj:~#virsh
 dominfo raj
How
To Clone Virtual Machine
raj@raj:~#virt-clone
--original oldvnname --name  newvmname --file /path/of/store/vm
How
To Login 
raj@raj:~#virsh
virsh
# console raj 
Connected
to domain raj 
Escape
character is ^] 
Ubuntu
12.04.5 LTS raj ttyS0 
raj
login: username
password:
KVM
error: Unable to read from monitor: Connection reset by peer Solved
raj@raj:~#
virsh start my machine
error:
Failed to start domain mymachine
error:
Unable to read from monitor: Connectionreset by peer
Solution:-
raj@raj:~#
virsh managedsave-remove mymachine
Removed
managedsave image for domain mymachine
raj@raj:~#
virsh start mymachine
Domain
mymachine started
FOR Import img file
virt-install -n vmname -r 2048 --os-type=ubutnu --os-variant=ubuntuprecise --disk /kvm/images/disk/vmname_boot.img,device=disk,bus=virtio -w bridge=br0/vidr0,model=virtio --vnc --noautoconsole --import
Nice Work ,,, Bhai
ReplyDelete