Tag Archives: ubuntu

Building libguestfs from source tarballs on Debian and Ubuntu

It is now possible to build libguestfs from the source tarballs on Debian and Ubuntu (into .deb packages which can be installed and managed by apt/aptitude). You will need libguestfs ≥ 1.11.6.

It’s not exactly obvious how, so this guide describes how to do it.

You’ll first need to install febootstrap 3.3, which you can either build from source in a similar way, or simpler you can install the binary package from here.

You will also need pretty recent Debian/Ubuntu. Suggested source repositories are here. In particular kernel ≥ 2.6.36 is absolutely required on the host. Earlier kernel versions than this won’t work.

Debian and Ubuntu do not supply /sbin/insmod.static. For the suggested workaround, read this.

You will also need to install several packages, but the first time you run the debuild command, it should tell you exactly what you are missing.

Grab the libguestfs source tarball ≥ 1.11.6 from the website, and unpack it:

$ zcat libguestfs-1.11.6.tar.gz | tar xf -
$ cd libguestfs-1.11.6

You can now run debuild with the right collection of options to build. The first time you do this, it will probably tell you that you need to install a bunch of build-time dependencies.

$ debuild -i -us -uc -b 2>&1 | tee /tmp/log

If it doesn’t work you’ll need to go back over the log file.

Once that works, in the parent directory (ie. above the build directory) you should find several .deb files:

$ cd ..
$ ls -l
$ ls -l
total 5280
-rw-r--r--  1 rjones rjones  347640 May 12 14:27 guestfish_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones  181368 May 12 14:27 guestmount_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones  941416 May 12 14:27 libguestfs0_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones 1235918 May 12 14:27 libguestfs0-dbg_1.11.6-1_amd64.deb
drwxr-xr-x 38 rjones rjones    4096 May 12 14:27 libguestfs-1.11.6
-rw-r--r--  1 rjones rjones  561346 May 12 14:28 libguestfs_1.11.6-1_amd64.build
-rw-r--r--  1 rjones rjones    3637 May 12 14:27 libguestfs_1.11.6-1_amd64.changes
-rw-r--r--  1 rjones rjones  408490 May 12 14:27 libguestfs-dev_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones  364450 May 12 14:27 libguestfs-doc_1.11.6-1_all.deb
-rw-r--r--  1 rjones rjones  454984 May 12 14:27 libguestfs-perl_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones  578720 May 12 14:27 libguestfs-tools_1.11.6-1_amd64.deb
-rw-r--r--  1 rjones rjones  262584 May 12 14:27 python-guestfs_1.11.6-1_amd64.deb

You can just install these using dpkg -i or however you would normally install .deb packages.

Finally make sure everything is working by running libguestfs-test-tool.

Leave a comment

Filed under Uncategorized

libguestfs 1.9.6 packages for Debian and Ubuntu

Debian packages and Ubuntu packages. Note that 1.9.6 is a development version.

Leave a comment

Filed under Uncategorized

New (Year’s) libguestfs tools: virt-copy-in, virt-copy-out, virt-tar-in, virt-tar-out

One aim with libguestfs development is to make easy and common file operations easy. Although you can already upload and download files into virtual machines using guestfish commands, is there a way to make this common operation easier to discover?

One way is to add more virt commands, which I’ve found that users have least difficulty discovering because they are on the website, autocompleted when you hit virt-[tab], and listed as separated manual pages.

So today I added four more commands for uploading and downloading: virt-copy-in, virt-copy-out, virt-tar-in, virt-tar-out.

The way you use them is very simple:

$ mkdir homes
$ virt-copy-out -d Fedora14 /home homes/
$ virt-tar-out -d Fedora14 /home - | \
    gzip --best > homes.tar.gz

These commands are just small shell script wrappers around guestfish, but I hope they make common things a little bit easier.

You can get these new commands from Fedora Rawhide, or as binaries for Debian or Ubuntu.

Leave a comment

Filed under Uncategorized

libguestfs 1.8.0 released

libguestfs is a set of tools and a library for accessing, creating and modifying the contents of virtual machines and disk images.

SourceFedora 14Ubuntu packagesDebian packagesArchLinux packages (thanks Thomas S. Hatch)

The full release notes for 1.8 are here.

Leave a comment

Filed under Uncategorized

Tip: Creating throwaway appliances with febootstrap

This is an update to a previous posting, but using the new febootstrap 3.x cross-distro toolchain to make building supermin appliances even simpler.

Firstly we create a supermin appliance containing a few packages and their dependencies. Note that I’m not minimizing this appliance so it’s a bit bigger (3.1MB!) than the ones we would generate in reality:

$ mkdir supermin.d
$ febootstrap --names 'bash' 'coreutils' -o supermin.d
febootstrap: warning: some host files are unreadable by non-root
febootstrap: warning: get your distro to fix these files:
$ ls -lh supermin.d/
total 3.1M
-rw-rw-r--. 1 rjones rjones 2.7M Dec 10 18:23 base.img
-rw-rw-r--. 1 rjones rjones 462K Dec 10 18:23 hostfiles

The purpose of these two files is explained in the febootstrap documentation.

This won’t boot without a /init script, and we can easily provide one:

$ cat init
#!/bin/bash -
echo Welcome to my world
bash -i
$ chmod +x init
$ echo init | cpio -o -H newc --quiet > supermin.d/init.img

The 3 files in supermin.d/ are a supermin appliance, and could be packaged up in a Fedora, Debian or Ubuntu package.

When you actually want to come and launch this appliance, you use febootstrap-supermin-helper to reconstruct the appliance:

$ febootstrap-supermin-helper -f ext2 supermin.d x86_64 \
    kernel initrd root

(Note that “kernel”, “initrd” and “root” are output files in that command)

You’d usually arrange for those files to be cached, since febootstrap-supermin-helper takes a few seconds to run (8 seconds on my laptop) and by caching it you can get reconstruction time down to a fraction of a second.

Now to boot, run qemu or qemu-kvm like this:

$ qemu-kvm -kernel kernel -initrd initrd -hda root

After a few seconds you’ll get to the shell:


Filed under Uncategorized

Ubuntu packages for libguestfs

You can download Ubuntu packages (*.deb files) for libguestfs. Don’t forget to read the README file.

Previously: Debian packages.

Leave a comment

Filed under Uncategorized

libguestfs binaries for Debian and Ubuntu

Over the weekend I rewrote the way supermin appliance building works to make it much more lightweight and mostly distro-independent. As a result, libguestfs now builds from source reasonably simply on both Debian and Ubuntu.

I’m also able to make binaries available for Debian and Ubuntu (10.10), but you must read the README file first.

If these do/don’t work for you, please let me know.


Filed under Uncategorized

Building libguestfs from source with the binary appliance

Inspired by this comment and reply I wrote a short tutorial which explains how to build libguestfs from source, but using the binary appliance that we ship.


This is essentially a very easy way to build libguestfs if it hasn’t been ported to your Linux distro, or if you have to rely on some appliance builder which is frequently not working.

1 Comment

Filed under Uncategorized

Notes: compiling libguestfs from source on Ubuntu 10.04

These are just notes that I made while compiling libguestfs on Ubuntu.

Note (1): Interested in maintaining libguestfs on Ubuntu? We really need a dedicated, skilled packager to help us out.

Note (2): More information is available on the libguestfs homepage, and for detailed help please send a message to the mailing list.

Start with the tarball. I am using libguestfs-1.5.12.tar.gz from here.

You need to install a boatload of dependencies. Luckily, they are all (except one) in Ubuntu repositories already, so they are just an “apt-get” and a moderate wait away:

$ sudo apt-get install \
  libfindlib-ocaml-dev ocaml-native-compilers \
  libxml-light-ocaml-dev \
  debootstrap debirf \
  libpcre3-dev libaugeas-dev libmagic-dev \
  libxml2-dev libvirt-dev \
  kvm \
  libreadline-dev \
  gcc make \

You need libhivex0 and libhivex-dev too. Ubuntu doesn’t have these, but these two packages from Debian squeeze worked fine for me: libhivex0, libhivex-dev.

Unpack the tarball and configure like this:

$ ./configure \
  --with-repo=lucid \

If you’re using a different version of Ubuntu from me, change “lucid” to whatever is appropriate. It needs to exactly match your host version.

Obviously ./configure needs to get all the way through. If there is a missing dependency, install it too. If all goes well it will print a summary of what it is going to compile which will look something like this:

Thank you for downloading libguestfs 1.5.12

This is how we have configured the optional components for you today:

Daemon .............................. yes
Appliance ........................... yes
QEMU ................................ /usr/bin/qemu-system-x86_64
OCaml bindings ...................... yes
Perl bindings ....................... yes
Python bindings ..................... no
Ruby bindings ....................... no
Java bindings ....................... no
Haskell bindings .................... no
PHP bindings ........................ no
virt-inspector ...................... no
virt-* tools ........................ no
supermin appliance .................. no
FUSE filesystem ..................... no

If you want more of those features to be enabled, you’ll need to track down the missing optional dependencies by reading back over the full configure output.


$ make

During the build, libguestfs will build a small Ubuntu-based appliance using debirf. It needs network access to fetch the .debs for this (using squid can help a lot). It’s also possible to use a local repository in which case network access won’t be required, although it doesn’t work by magic — you still have to supply the .debs from somewhere.

You might need to adjust appliance/packagelist.in and/or files in appliance/debian/modules/ if a package is missing or if appliance building fails. On Ubuntu 10.04 I had to comment out the “find” statement where it was trying to delete unused kernel modules (bug in debirf I suspect) and comment out the apt-get remove command.

Building the appliance is generally the most error-prone part of the whole process because it depends on infrequently tested parts of Debian such as debirf, debootstrap, fakeroot and packages themselves. If you have no patience for this you can grab the pre-built binary appliance from our binary distribution (also use ./configure --disable-appliance).

Now once you’re through the build, check that things work. You can do a quick “does it work at all” check:

$ make quickcheck

(Obviously if this fails, you need to go back and take a hard look at the build).

Finally run the full test suite:

$ make check

[Fix the bugs and submit patches!]

You can now try running guestfish etc.


Filed under Uncategorized

libguestfs binaries for all Linux distros

I uploaded some distro-independent Linux/x86-64 binaries of libguestfs, guestfish, guestmount and the virt-* tools. Be sure to read the README file first.

These are a little experimental and I’d welcome feedback. I got them to work fine on Debian 5.0 after upgrading glibc and Perl, but YMMV.

Update: OpenSUSE 11.3 working.

The version of KVM supplied is too old (doesn’t support virtio-serial) so I had to compile qemu from git and drop the following qemu wrapper in place:

#!/bin/sh -
exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "$@"

The next problem which had me confused for a very long time was that qemu kept aborting while allocating memory. After trying things like adding swap, playing with overcommit settings and so on, it turned out that SUSE uses some really silly, and very small default ulimits for virtual memory. You have to do:

ulimit -Hv unlimited
ulimit -Sv unlimited
ulimit -Hm unlimited
ulimit -Sm unlimited

Update: Ubuntu 10.04 working.

As with SUSE, the version of KVM shipped by Ubuntu is too old to support virtio-serial. All I had to do was replace it with qemu from git and the same qemu wrapper above.

After that guestfish works fine.

If you need the Perl tools, then you have to upgrade Perl to 5.12.1, install hivex, and link libpcre.so.0 -> libpcre.so.3.

Leave a comment

Filed under Uncategorized