Jaime Frutos Morales's blog

07/03/2011

TIP: Configuring a scanner in VirtualBox

Filed under: Virtualization — acidborg @ 13:32

Yesterday, I spent a couple of hours finding out why a HP Deskjet 2050 wasn’t working on a virtualized Windowx XP using VirtualBox. It seems that VirtualBox’s scanner support is far from complete, so some scanners aren’t supported at all. I was lucky and I could manage my scanner to work.

TIP: If you disable the “Enable USB 2.0 (EHCI) Controller”, some scanners may run on a virtualized Windows XP.

VirtualBox disable EHCI USB 2.0 (EHCI) Controller option

17/09/2010

How to automatically start KVM virtual machines on boot

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:18

Description: when you have a host machine running KVM and it runs several guests (virtual machines), it’s very useful to make them start on boot so that you don’t have to start them manually.

Steps:
Just execute the following command for each guest you want to autostart on boot: virsh autostart guest_name .

22/02/2010

How to make a live migration of a KVM virtual machine using virsh and SSH

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:32

Description: A KVM virtual machine (guest) can be easily migrated from one host to another using virsh and SSH. The goal is to migrate guests without stopping them and with almost no downtime. This is very useful to balance the load among the hosts and to manage maintenance tasks.

Requirements:

  • The guest image must be located on a shared storage and it must be accessible using iSCSI, NFS, GFS2 or Fibre Channel.
  • The shared storage must be mounted on the same path on both hosts.
  • Both guests must run the same version of KVM.
  • Both guests must have the same network configuration and bridging configuration (their IPs must be different, of course).

Steps:

  • Verify that the guest is running on the source host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running
  • Migrate the guest: virsh migrate --live test_guest qemu+ssh://destination_server/system
  • If you haven’t shared a pair of SSH keys between the hosts (highly recommended), enter the password.
  • Wait until the migration is completed (the guest will continue running until the end of the process).
  • Verify that the guest is running on the destination host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running

19/02/2010

How to manage KVM virtual machines using virsh

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:17

Description: virsh is a program which uses libvirt to manage KVM virtual machines (guests). I’m going to show a summary of its main functions (cheat sheet style):

Show guests’ information:

  • Show a list of all the defined guests: virsh list --all
  • Show a guest’s info: virsh dominfo guest's_name

Start and stop guests:

  • Start a guest: virsh start guest's_name
  • Shutdown a guest (gently): virsh shutdown guest's_name
  • Shutdown a guest (wild): virsh destroy guest's_name
  • Suspend a guest: virsh suspend guest's_name
  • Resume a suspended guest: virsh resume guest's_name

Create and modify guests:

  • Create a new guest
  • Create a guest from its XML definition: virsh create xml_file.xml
  • Dump a guest’s definition in XML: virsh dumpxml guest's_name
  • Modify a guest’s definition: virsh edit guest's_name
  • Remove a guest’s definition (it doesn’t remove the image file): virsh undefine guest's_name

Backup and restore guests:

  • Save a guest’s state on a file: virsh save guest's_name guest's_state_file
  • Restore a guest from a state file: virsh restore guest's_state_file

I’m going to explain guests live migration on another post to keep this cheat sheet simple.

18/02/2010

How to create virtual machines using KVM (Kernel-based Virtual Machine)

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:24

Description: KVM is a virtualization infrastructure included in the Linux kernel since 2.6.20 . Although it supports some kinds of paravirtualization, I’m going to explain how to create virtual machines /also called guests) using its full virtualization support.

Steps:

  1. Check if your processor supports full virtualization (if either vmx or svm appears as a flag, then your processor supports it): egrep '(vmx|svm)' --color=always /proc/cpuinfo
  2. Install the packages needed:
    • Debian/Ubuntu: apt-get install kvm libvirt0 python-libvirt python-virtinst
    • Red Hat/Fedora: yum install kvm libvirt libvirt-python python-virtinst
  3. Configure a bridge (Debian/Ubuntu or Red Hat/Fedora) to use a single network interface for all your virtual machines.
  4. Create the virtual machine (a RHEL 5 virtual machine in this example): virt-install --name=guest_name --arch=x86_64 --vcpus=1 --ram=512 --os-type=linux --os-variant=rhel5 --hvm --connect=qemu:///system --network bridge:br0 --cdrom=/var/lib/libvirt/images/rhel5-x86_64.iso --disk path=/mnt/virtual_machines/guest_name.img,size=20 --accelerate --vnc --noautoconsole --keymap=es
    Explanation of the params:

    • name: name of the guest.
    • arch: architecture of the guest.
    • vcpus: number of CPUs assigned to the guest.
    • ram: MB of RAM assigned to the guest.
    • os-type and os-variant: available options can be checked using man virt-install.
    • hvm: use full virtualization.
    • connect: connect to the hypervisor.
    • network bridge: the bridge to use for the guest.
    • cdrom: the ISO of the operating system to install.
    • disk path=x,size=y: path and size of the image file for the guest.
    • accelerate: make use of the KVM acceleration capabilities if available.
    • vnc: export a virtual console over VNC to the guest.
    • noautoconsole: Don’t automatically try to connect to the guest console.
    • keymap: keyboard layout for the VNC console
  5. Use a VNC client to connect to the guest (port 5900 or 5901 if you already have a VNC server listening on port 5900) and install the operating system.

I’ll write another post soon explaining all the operations which can be done with KVM virtual machines using virsh.

Blog at WordPress.com.