Step to configure
KVM Virtulation on Ubuntu
1 => install
packages
#apt-get
install kvm qemu-kvm libvirt-bin virtinst bridge-utils
2 => Create
bridge network
=> Open file and
make entry like below according to your network
#vim
/etc/network/interfaces
auto eth0
iface eth0 inet static
# address
10.0.3.37
# netmask
255.255.0.0
# network
10.0.0.0
# broadcast
10.0.255.255
# gateway
10.0.0.13
# # dns-* options
are implemented by the resolvconf package, if installed
# dns-nameservers
8.8.8.8
auto br0
iface br0 inet static
address
10.0.3.37
network
10.0.0.0
netmask
255.255.0.0
broadcast
10.0.255.255
gateway
10.0.0.13
dns-nameservers
8.8.8.8
bridge_ports
eth0
bridge_fd 9
bridge_hello 2
bridge_maxage
12
bridge_stp off
=> Save file and
exit
=> Now restart
your network
#/etc/init.d/networking
restart
3 => Mount Ubuntu
server os iso
#mount
-o loop /opt/ubuntu-12.04.3-server-amd64.iso /mnt/
mkdir
/opt/lampp/htdocs/ubuntu
rsync
-av /mnt/ /opt/lampp/htdocs/ubuntu/
Note:
I am using lampp server to share os with http
4 => Create guest
os with below command
#mkdir
/opt/VT
=> For Graphical
from local media
virt-install
--connect qemu:///system -n dbsrv -r 1024 --vcpus=1 --disk
path=/var/lib/libvirt/images/dbsrv.img,size=15 -c
/var/lib/libvirt/images/ubuntu-12.04.3-server-amd64.iso --vnc
--os-type linux --accelerate --hvm
=>
For Command (I am
using Command mode)
virt-install
--name dbsrv --ram 4096 --vcpus=2 --nographics --location
/opt/ubuntu-12.04.3-server-amd64.iso --disk
path=/opt/VT/dbsrv.img,size=512 -x "console=ttyS0";
: Select language
: Select location
United states
: Select ( No )
: Select English
(US)
: Select English
(US) and press enter
:Select Configure
network manually and press enter
: Give ip address
according to your network and press enter
: Give netmask and
press enter
: Give Gateway and
press enter
: Give DNS and press
enter
: Give hostname and
press enter
: Choose United
states and press enter
: Press enter like
below
: Give your local
http share detail for OS folder
: Give username for
your system and press enter
: Give password for
your user
: Select (No) when
ask to encrypt your home directory
: Select ( Select
from worldwide list)
: Select Kolkata in
time zone
: Select manual to
create hard disk partition
: Select your hdd
which you defined and press enter
:Select No
and press enter
: Select free space
and press enter
: Select create a
new partition and press enter
:Give size for
partition and press enter
: Select Primary
and press enter
: Select Beginning
and press enter
: Select Done
setting up the partition and prss enter
Note : Create
partition as previous according to your need
: Select Yes to
write the changes to disk
: Select No
Automatic updates
: Select software
according to your need
: Select Yes to
install GRUB boot loader
: Select No
Select Continue and
press enter
: Now your guest
system will reboot and give a login prompt like below
Operarions with virsh command
1 => To Start Virtual Machine use below
command
#virsh
start dbsrv
2 => To start and connect to console of
'dbsrv'
#virsh
start www --console
3 => To Stop
Virtual Machine 'dbsrv'
#virsh
shutdown dbsrv
4=> To Stop
fourcely Virtual Machine 'dbsrv'
#virsh
destroy dbsrv
5 => To enable
auto-start for 'dbsrv'
#virsh
autostart dbsrv
6 => To disable
auto-start for 'dbsrv'
#virsh
autostart --disable dbsrv
7 => To list all
active Virtual Machines
#virsh
list
8 => To list
all Virtual Machines include inactives
#virsh
list --all
9 => To connect
to 'dbsrv'
#virsh
console dbsrv
Connected to domain
www
Escape character is ^] # Press Enter key to get login prompt
Escape character is ^] # Press Enter key to get login prompt
10 => To close
guest console press ctrl + 5
11 => To get
help
12 => To delete
guest OS permanentlly
#virsh
destroy dbsrv
#virsh undefine dbsrv
#virsh
–help
13 => To extend
disk size for guest in KVM
#qemu-img resize
VT-NEMR-PATCH.img +390G
14 => To reduse disk
size for guest in KVM
#qemu-img resize
VT-NEMR-PATCH.img -190G
Thanks
Nirmal
Singh