User:Jack Palmadesso

From Amahi Wiki
Revision as of 02:25, 26 October 2011 by Jack Palmadesso (talk | contribs)
Jump to: navigation, search

Intro

The following tutorial is a pretty advanced topic. I will attemmpt to do my best in being as clear as possible but you need to be warned that if you have not worked with Linux for very long you might get lost.

For a few years now the Linux kernel has had the ability to run virtual machines natively. Most people think of Vmware or Virtual Box when they want to run virtual machines. These are good products and have come a long way in making virtualization a reality. While it is possible to get these products for "free" and use them there are drawbacks to using these products. For the most part these mainstream products are streamlined and present a nice gui to an end user. These usually do a good job in making the complex task of virtualizing a machine simple but there are drawbacks. The "free" versions usually disable some really nice features like "snapshots" or they might restrict the amount of resources that can be assigned to a Virtual Machine.

There are also the problems. The guis can be a bit buggy and not always work correctly. Of course support is not going to be possible so you will have to live with the problems until the next update. With Vmware and Virtual Box there are also some packages that need to be installed in the guest to make them work "properly". This is usually some form of driver that makes the Virtual Machine aware its being virtualized or presents a layer to trick the Virtual Machine into thinking its on some real hardware.

I am not knocking these products. There are quite a few out there now and its really amazing how far they have come. I actually remember around the year 2000 when Vmware was giving away its product for free with Suse Linux. They were the only one in the space at that time. Now there are dozens of products and most of them work pretty well. At this point in time virtualization is just a fact so the various OS vendors are now building vitualization into thier product. Microsoft has Hyper-V, Oracle has Virtual Box and Solaris Zones, and all Linux distros have the ablility to run either Xen, or KVM based virtual machines. Xen is on the decline in favor of KVM now.

Its pretty safe to say that if you use the native products that are built into the OS you will enjoy an advantage over a product that you add-on. Think Microsoft and Internet Explorer or Apple and iTunes. These applications will enjoy lots of advatages over competing products because they can take advantage of some unpublished hooks. These hooks will give the native applications many advantages over competing products that are installed afterwords. Native Virtualization is no exception to this rule. This is especially true if the VM is the same OS as the Host OS.

The purpose of this wiki page is to give Amahi developers an intro to native Linux virtualization. Any Linux distribution can be used. Its only a matter of installing the right packages. These days with YUM and APT its only a command or two away and you don't even need to reboot. Take that Microsoft !!

Seriously though I hope you all get something out of this. I've been working with Linux for a long time now (10+ years) and I make my living now from working with it daily. As the Suse guys say "Have alot of fun!"

Prepare Prepare Prepare!!

This is going to take some time so get yourself comfortable. Maybe get some music going in the background and get a drink or something, seriously. For this example I am using the Host or Hypervisor is running on Fedora 15 x64. Do yourself a favor and make the Host 64 bit because you really need to take advantage of the RAM. Here are my Host/Hypervisor specs:

  • Dual core 3ghz proc
  • 4gb RAM
  • 80 gb OS drive (Fedora 15 X64 Installed)
  • 160 gb drive (to be used for the VM images)

Nothing special about it right, but to take advantage of the 4gb or RAM you need 64 bit, especially if you have more RAM than I have here. As I mentioned I am using Fedora which is what Amahi users are used to so this will be biased towards Fedora.

You will need the following information which will be used later on
  1. Enable Virtualization in your BIOS !! Don't overlook this !!
    • If there is no virtualization options in your bios then either your board or cpu do not support it. If that is the case then stop here because your experience will be poor at best.
  2. Update your System !!
    • su -c yum -y update
  3. Install the needed Packages
    • su -c yum -y install kvm virt-manager qemu-kvm.x86_64 qemu-kvm-tools.x86_64 qemu.x86_64 qemu-common.x86_64 qemu-kvm.x86_64 qemu-kvm-tools.x86_64 sheepdog.x86_64 virt-v2v.x86_64 mc nmap
    • This might take some time so take a break or something
  4. Your Drive ID or model number.
    • You can get this by installing the "sdparm" package
    • sdparm /dev/sdb
    • Copy down the model number
    • In my case: sudo -c sdparm /dev/sdb
    • /dev/sdb: ATA ST3160815AS 3.AA
    • You want the stuff in bold recorded somplace
    • You can also get this same info from the "Disk Utility" app which is gui based.
  5. Once all the packages are installed you need to check some things.
    • Make sure the kernel modules are loaded
      • lsmod |grep kvm
      • Should give
        • kvm and either kvm_intel or kvm_amd
        • kvm should always be there and one of the other two should be there depending on your cpu type. My output was like this:
        • kvm_intel 44819 0
        • kvm 317840 1 kvm_intel