virt-diff is a simple tool I wrote yesterday to display the differences between two virtual machine disk images. Some ways you could use this include:
- Run an installer on a virtual machine and see what files the installer creates or modifies.
- See what changes a tool like virt-sysprep is making to a disk image.
- Reverse engineer changes made by config programs like wicd.
It should work on any Linux or Windows disk image, but it’s a bit rough and ready at the moment.
Anyway I’m going to use it to show what changes virt-builder makes to the template when it builds an operating system image.
Run virt-builder to create an OS:
$ virt-builder fedora-19 \
--root-password password:123456 \
--edit '/etc/fedora-release: s/Schrödinger/Henry/'
[ 1.0] Downloading: http://libguestfs.org/download/builder/fedora-19.xz
[ 2.0] Planning how to build this image
[ 2.0] Uncompressing
[ 16.0] Opening the new disk
[ 36.0] Setting a random seed
[ 36.0] Setting root password
[ 36.0] Editing: /etc/fedora-release
[ 36.0] Finishing off
Output: fedora-19.img
Output size: 4.0G
Output format: raw
Total usable space: 1.9G
Free space: 1.2G (65%)
When virt-builder ran, it downloaded or used a Fedora 19 template, which it saved in its cache. Let’s fish out that template:
$ xzcat ~/.cache/virt-builder/fedora-19.1 > fedora-19-original.img
Finally use virt-diff to show the differences (what virt-builder changed compared to the downloaded template):
$ virt-diff -a fedora-19-original.img -A fedora-19.img = - 0644 41 /etc/fedora-release @@ -1 +1 @@ -Fedora release 19 (Schrödinger’s Cat) +Fedora release 19 (Henry’s Cat) @@ End of diff @@ = - 0000 672 /etc/shadow @@ -1,4 +1,4 @@ -root:$6$/hQ0mnIY.tM0f/FB$6bjUN2Dophh9VTN3MBeeSHCgAClesYsdLcb/u/8b5sSbmWAgQyUfBPCcHBV6KfbzsfHiIhWtW155b096t31P70:15979:0:99999:7::: +root:$6$vU.BupZx3RCtreCl$6EJnzCB4MhjnYmNX7sdi//IqysqKzsp2PmtYgykFfzIlIF5gnqPANVXRTFV2CdflyOpBSCIR7rAmv/s4etWHZ/:15979:0:99999:7::: bin:*:15863:0:99999:7::: daemon:*:15863:0:99999:7::: adm:*:15863:0:99999:7::: @@ End of diff @@ = - 0600 8 /var/lib/random-seed @@ End of diff @@
As expected, virt-builder set root’s password, edited the file, and set a new random seed (not shown because it’s binary).

Pingback: libguestfs 1.26 released | Richard WM Jones