Virtualization With KVM On A Mandriva 2010.0 Server
|
Submitted by falko (Contact Author) (Forums) on Tue, 2010-03-23 18:07. :: KVM | Mandriva | Virtualization
Virtualization With KVM On A Mandriva 2010.0 ServerVersion 1.0 This guide explains how you can install and use KVM for creating and running virtual machines on a Mandriva 2010.0 server. I will show how to create image-based virtual machines and also virtual machines that use a logical volume (LVM). KVM is short for Kernel-based Virtual Machine and makes use of hardware virtualization, i.e., you need a CPU that supports hardware virtualization, e.g. Intel VT or AMD-V. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm using a Mandriva 2010.0 server with the hostname server1.example.com and the IP address 192.168.0.100 here as my KVM host. We also need a desktop system where we install virt-manager so that we can connect to the graphical console of the virtual machines that we install. I'm using a Mandriva 2010.0 desktop here.
2 Installing KVMMandriva 2010.0 KVM Host: First check if your CPU supports hardware virtualization - if this is the case, the command egrep '(vmx|svm)' --color=always /proc/cpuinfo should display something, e.g. like this: [root@server1 administrator]# egrep '(vmx|svm)' --color=always /proc/cpuinfo If nothing is displayed, then your processor doesn't support hardware virtualization, and you must stop here. To install KVM and virtinst (a tool to create virtual machines), we run urpmi kvm libvirt0 python-virtinst libvirt-utils Then start the libvirt daemon: /etc/init.d/libvirtd start To check if KVM has successfully been installed, run virsh -c qemu:///system list It should display something like this: [root@server1 administrator]# virsh -c qemu:///system list If it displays an error instead, then something went wrong. 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. To do this, we install the package bridge-utils... urpmi bridge-utils ... and configure a bridge. To configure the bridge, create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the BOOTPROTO, DNS1 (plus any other DNS settings, if any), GATEWAY, IPADDR, NETMASK and SEARCH values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file): vi /etc/sysconfig/network-scripts/ifcfg-br0
Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follows (comment out BOOTPROTO, DNS1 (and all other DNS servers, if any), GATEWAY, IPADDR, NETMASK, and SEARCH and add BRIDGE=br0): vi /etc/sysconfig/network-scripts/ifcfg-eth0
Restart the network: /etc/init.d/network restart Then run ifconfig It should now show the network bridge (br0): [root@server1 administrator]# ifconfig
3 Installing virt-manager On Your Mandriva 2010.0 DesktopMandriva 2010.0 Desktop: We need a means of connecting to the graphical console of our guests - we can use virt-manager for this. I'm assuming that you're using a Mandriva 2010.0 desktop. Become root... su ... and run... urpmi virt-manager ... to install virt-manager. (If you're using an Ubuntu 9.10 desktop, you can install virt-manager as follows: sudo aptitude install virt-manager )
4 Creating A Debian Lenny Guest (Image-Based)Mandriva 2010.0 KVM Host: Now let's go back to our Mandriva 2010.0 KVM host. Take a look at man virt-install to learn how to use it. To create a Debian Lenny guest (in bridging mode) with the name vm10, 512MB of RAM, two virtual CPUs, and the disk image ~/vm10.qcow2 (with a size of 12GB), insert the Debian Lenny Netinstall CD into the CD drive and run virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c /dev/cdrom --vnc --noautoconsole --os-type linux --os-variant debianlenny --accelerate --network=bridge:br0 --hvm Of course, you can also create an ISO image of the Debian Lenny Netinstall CD... dd if=/dev/cdrom of=~/debian-500-amd64-netinst.iso ... and use the ISO image in the virt-install command: virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/debian-500-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant debianlenny --accelerate --network=bridge:br0 --hvm The output is as follows: [root@server1 administrator]# virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/debian-500-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant debianlenny --accelerate --network=bridge:br0 --hvm Now we must reconfigure our SSH daemon so that it allows root connections (so that we can connect from our Mandriva 2010.0 desktop as root). Open /etc/ssh/sshd_config... vi /etc/ssh/sshd_config ... and change the PermitRootLogin line as follows:
Restart the SSH daemon afterwards: /etc/init.d/sshd restart
|




Recent comments
3 hours 49 min ago
4 hours 49 min ago
8 hours 36 min ago
9 hours 50 min ago
13 hours 26 min ago
20 hours 41 min ago
1 day 5 hours ago
1 day 7 hours ago
1 day 22 hours ago
2 days 35 min ago