Tag Archives: virt-tools

Quick tip: Create a CentOS 6 guest with EPEL packages

You can use virt-builder [≥ 1.26] to create guests with packages from other repositories, like this:

$ virt-builder centos-6 \
    --run-command 'rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm' \
    --update \
    --install cloud-utils,cloud-init

(cloud-utils & cloud-init are examples of packages that are only available in EPEL)

3 Comments

Filed under Uncategorized

Mini-cluster (mclu) command line tool

After setting up my virtualization cluster I was disappointed by the available cluster management tools. You can either “go large” (Openstack) with all the associated trauma of setting that up, or go with various GUIs. Or you can run ssh & virsh commands, which gets tedious quickly.

Therefore I wrote some simple scripts to help perform common cluster operations on small clusters (up to about 10 nodes). It’s only 1000 lines of code, and the advantage is you only need sshd and libvirtd on each node, which you almost certainly have already.

You can download them from this git repository.

Get cluster status:

$ mclu status
ham0 (ham0.home.annexia.org) down
ham1 (ham1.home.annexia.org) down
ham2 (ham2.home.annexia.org) down
ham3 (ham3.home.annexia.org) down
$ mclu wake --all
$ mclu status
ham0 (ham0.home.annexia.org) up ssh: OK libvirt: OK
ham1 (ham1.home.annexia.org) up ssh: OK libvirt: OK
ham2 (ham2.home.annexia.org) up ssh: OK libvirt: OK
ham3 (ham3.home.annexia.org) up ssh: OK libvirt: OK

Build a new VM (using virt-builder):

$ mclu build --size=20G -- \
   ham0:tmp-f20-1 fedora-20 \
   --root-password password:123456

List running VMs, live-migrate the new one around:

Note that wildcards can be used when starting, stopping and migrating VMs:

$ mclu list
ham0:tmp-f20-1	running
$ mclu migrate \* ham2:
$ mclu list
ham2:tmp-f20-1	running
$ mclu stop ham2:*
$ mclu list
tmp-f20-1	inactive

Open a console

$ mclu start ham3:tmp-f20-1
$ mclu console tmp-f20-1
Connected to domain tmp-f20-1
Escape character is ^]
^]
$ mclu viewer tmp-f20-1
(graphical window opens)

8 Comments

Filed under Uncategorized

virt-builder RHEL 7 release candidate

You can now install RHEL 7 release candidate (very unofficially) through virt-builder on Fedora 20).

Just do:

$ virt-builder rhel-7rc
[   0.0] Downloading: ***
[   1.0] Planning how to build this image
[   1.0] Uncompressing
[   6.0] Opening the new disk
[  53.0] Setting a random seed
[  53.0] Setting passwords
Setting random password of root to ***
[  53.0] Finishing off
Output: rhel-7rc.img
Output size: 6.0G
Output format: raw
Total usable space: 4.8G
Free space: 4.0G (82%)

To be honest with you I couldn’t get networking to work, so if it works at all for you then let us know how. The network worked once I supplied the right qemu options.

Leave a comment

Filed under Uncategorized

Tip: Use virt-builder to install Fedora packages from updates-testing

Virt-builder ≥ 1.26 now lets you flexibly edit configuration files before you install packages. (1.24 didn’t). So finally you can enable the Fedora updates-testing repository and build a guest with packages from that:

$ virt-builder fedora-20 \
  --edit '/etc/yum.repos.d/fedora-updates-testing.repo:
            s/enabled=0/enabled=1/' \
  --install git,emacs,yum-utils,net-tools,libguestfs
[   0.0] Downloading: http://libguestfs.org/download/builder/fedora-20.xz
[   1.0] Planning how to build this image
[   1.0] Uncompressing
[  11.0] Opening the new disk
[  16.0] Setting a random seed
[  16.0] Updating core packages
[ 269.0] Editing: /etc/yum.repos.d/fedora-updates-testing.repo
[ 269.0] Installing packages: git emacs yum-utils net-tools libguestfs
[ 349.0] Setting passwords
Setting random password of root to ***
[ 349.0] Finishing off
Output: fedora-20.img
Output size: 4.0G
Output format: raw
Total usable space: 5.2G
Free space: 3.7G (71%)

Leave a comment

Filed under Uncategorized

a-fedora-appliance updated for supermin 5

a-fedora-appliance is a supermin demonstration Fedora appliance.

I have scratch-built a Fedora RPM here which is just a 235K download but contains (by magic!) a fully bootable Fedora appliance. After installing the RPM in Fedora 20, do the following to boot the virtual machine:

# boot-a-fedora-appliance

Screenshot - 310314 - 22:54:03

Note that the scratch build will only last in Koji for a few days. After that you’ll have to follow the README file included in the source.

Leave a comment

Filed under Uncategorized

libguestfs 1.26 released

Yesterday the new stable version of libguestfs (1.26) was released. There are many new features and you can find the release notes here.

On this blog I’ve covered a lot of the new features already:

Leave a comment

Filed under Uncategorized

Using virt-customize to make custom guests with a single backing file

Yesterday I hinted that virt-customize could be used to make custom guests sharing a single backing file. Here is how you do that.

Firstly download a cloud image, or use virt-builder to create one:

$ virt-builder fedora-20 -o backing.img
[   0.0] Downloading: http://libguestfs.org/download/builder/fedora-20.xz
[   1.0] Planning how to build this image
[   1.0] Uncompressing
[  11.0] Opening the new disk
[  15.0] Setting a random seed
[  15.0] Setting passwords
Setting random password of root to 8obMIvmrWe6CCkAv
[  16.0] Finishing off

Now use qemu-img to create overlays for each guest:

$ qemu-img create -b backing.img -f qcow2 guest1.img
$ qemu-img create -b backing.img -f qcow2 guest2.img

You must leave the backing file untouched. In particular don’t try to customize it, else you’ll corrupt all the guests using that backing file.

Now you can customize each guest overlay:

$ virt-customize -a guest1.img \
    --hostname guest1 --timezone Europe/London \
    --install gcc
[   0.0] Examining the guest ...
[   3.0] Setting a random seed
[   3.0] Setting the hostname: guest1
[   3.0] Setting the timezone: Europe/London
[   3.0] Installing packages: gcc

$ virt-customize -a guest2.img \
  --hostname guest2 --install /usr/bin/soffice
[   0.0] Examining the guest ...
[   5.0] Setting a random seed
[   5.0] Setting the hostname: guest2
[   5.0] Installing packages: /usr/bin/soffice

As expected, each guest overlay uses a different amount of space depending on what has been installed:

$ ls -lh guest?.img
-rw-r--r--. 1 rjones rjones 613M Mar 26 15:49 guest1.img
-rw-r--r--. 1 rjones rjones 924M Mar 26 16:04 guest2.img

6 Comments

Filed under Uncategorized