Crash course: Virtualization with KVM on Ubuntu Server

Learn how to get KVM running on Ubuntu Server, install multiple guests, manage storage, and migrate guests to new hosts

Page 4 of 4

Managing storage

The Virtual Machine Manager makes storage management easy and fast. Create additional storage pools by clicking Edit > Connection Details. This opens a screen with multiple tabs. The Storage tab shows your existing storage pools, and creates new ones. Start in the left pane, and click the green cross to allocate a new block of storage (Figure 5). This can be a directory, block device, SCSI host adapter, network filesystem, LVM group, or an ISCSI target. Then you can divide this up however you like in the right-hand pane. Click the New Volume button, configure its size, and choose either the raw or qcow2 disk image format because these work with all filesystems. raw is the default, and it is the fastest. qcow2 supports AES encryption, snapshots, and compression.

Figure 5: Creating and dividing new blocks of storage.

Migrating guests

You can migrate guests to a different host for load-balancing, for software or hardware maintenance, or just because you can. There is a prerequisite for enabling migration, and that is your hosts must use shared networked storage, such as NFS shares, Fibre Channel, iSCSI -- whatever it is, both the source and destination host must already be using the same shared network storage pool.

There are two types of migrations: offline and live. In an offline migration the guest is stopped, and then an image of the guest's memory is moved to the new host and restarted. In a live migration, KVM moves the guest's memory pages to the new host, monitors the old host for changes, and transfers these changes to the new host. When the pages are all copied and no changes occur for a configured period of time (10 milliseconds is the default) the guest is stopped on the old host and resumed on the new host. If the old host is busy, a live transfer can take a long time, or not complete at all, so then you'll need to stop it, and do an offline migration instead. Only the contents of the guest's memory are moved; its disk storage is not moved.

Migrating a guest is then a few simple clicks. From the main Virtual Machine Manager console, right-click on the guest you want to move, then left-click Migrate. Check "migrate offline" if you want an offline move. The New Host dropdown menu will list all the available KVM hosts. Select the one you want to use, click the Migrate button, and you're done.

Remote administration, CLI

Virtual Machine Manager supports remote administration. Install it on your favorite workstation or laptop, and then connect to your KVM server with this command:

$ virt-manager -c qemu+ssh://kvmhost/system

Replace kvmhost with your own server's hostname. This tunnels your session securely over SSH, so you'll need an SSH server running on your KVM server.

You may prefer to run your KVM server from the command line, which you can do. Consult the man pages for virt-manager, virsh, and qemu-kvm.

This concludes our crash course, but there's plenty more to learn such as security, the finer points of resource allocation, and best practices. Chapter 19 of the Ubuntu Server Guide is helpful, and the Red Hat Enterprise Linux 6 Virtualization Guide is the most thorough.

Good luck!

| 1 2 3 4 Page 4
ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon