Tag Archives: virt-sysprep

Tip: Set a root password on a disk image

virt-sysprep --enable customize --root-password password:123456 -a /dev/sdX

Useful when installing Fedora on ARM machines that only have a serial port.

Leave a comment

Filed under Uncategorized

New(ish) in libguestfs 1.27.23 — add firstboot batch files to Windows guests

You’ve been able to do this for a while by hand but now virt-sysprep & virt-customize ≥ 1.27.23 let you easily install firstboot scripts into Windows guests:

$ cat /tmp/test.bat
echo Hello I am a batch file
$ virt-customize -a win7.qcow2 --firstboot /tmp/test.bat

Next time the guest boots, check the log file in C:\Program Files\Red Hat\Firstboot\log.txt

This works well for me in Windows 7 guests. It ought to work in other Windows guests too. So far the only other Windows flavour I tested was W2K3 where the service crashed for some unfathomable reason (I’m not very patient with debugging Windows problems).

So let us know how it goes and we’ll try to fix the bugs as we go along.

Leave a comment

Filed under Uncategorized

libguestfs is 5 years old today


As we’re hard at work on the 1.26 release of libguestfs which is going to be a blockbuster, with massive improvements to virt-builder, a rewritten and much more flexible and robust appliance, a new guest customization tool, loads of new virt-sysprep features, rewritten virt-make-fs, and lots more .. it’s worth mentioning that libguestfs is 5 years old today.

The first commit was:

commit 28d760
Author: rjones <rjones>
Date:   Tue Mar 3 08:58:37 2009 +0000

    Build environment set up for libguestfs.

2 Comments

Filed under Uncategorized

virt-resize from an NBD source

New in libguestfs ≥ 1.23.23 is the ability to use virt-resize from a remote source.

One use for this is to use nbdkit’s xz plugin as a source, to easily create new images from highly compressed templates. In the example below nbdkit transparently (and in RAM) uncompresses the disk image, serving it up over /tmp/sock (a socket):

$ nbdkit -r -f -U /tmp/sock \
    /usr/lib64/nbdkit/plugins/nbdkit-xz-plugin.so \
    file=f17x64.img.xz

Virt-resize fetches the image from the socket and writes & resizes it to the destination file:

$ truncate -s 20G /tmp/output.img   # adjust target size
$ virt-resize 'nbd://?socket=/tmp/sock' /tmp/output.img
$ killall nbdkit; rm /tmp/sock

You can then use virt-sysprep to set the hostname and run configuration scripts in the output image.

Unfortunately you also have to temporarily disable SELinux for this to work, because SELinux prevents qemu from connecting to the NBD socket. Grrrr.

Leave a comment

Filed under Uncategorized

New in virt-sysprep: Set root and user passwords

New in virt-sysprep ≥ 1.23.13 is the ability to set root and user passwords in Linux guests (previous manual method is described here).

$ virt-sysprep \
  --root-password password:123456 \
  --password joe:file:/tmp/secret -a guest.img

You shouldn’t normally specify the cleartext password on the command line, although it’s useful for testing. You should usually provide a file containing the password, ensuring that it is not readable by other users on the system (ie. mode 0600).

4 Comments

Filed under Uncategorized

DigitalOcean not sysprepping their guests

Every new instance had the same SSH host key (Hacker News discussion).

virt-sysprep can help.

Leave a comment

Filed under Uncategorized

Recent libguestfs improvements

Nothing earth-shattering …

Support for setting UUIDs on filesystems. In particular, virt-sysprep will now choose random UUIDs for each filesystem in the guest (previously it only did this for LVM2 objects).

There’s a new add-drive-scratch API (and equivalent scratch in guestfish) which creates a temporary drive which is automatically discarded when the libguestfs handle closes.

You can now use:

guestfish -N filename=fs

to select an alternate name for the prepared disk image instead of the old test1.img, test2.img etc.

And lots of bug fixes

Leave a comment

Filed under Uncategorized

New in libguestfs (a round-up)

  1. Several APIs have been reimplemented so they don’t suffer from arbitrary protocol limits.
  2. Python bindings handle optional arguments properly now.
  3. The tar-out command has several extra (optional) arguments for choosing a range of compression types and other features.
  4. You can now use rsync to do incremental updates to / backups of your guests.
  5. ssh is included in virt-rescue
  6. virt-sysprep will now assign fresh UUIDs to your PVs and VGs

Leave a comment

Filed under Uncategorized

New in virt-sysprep: Add firstboot scripts

In libguestfs ≥ 1.19.32 you can now use the virt-sysprep to add “firstboot” scripts to Linux guests. These scripts run exactly once the next time the guest boots, so you can use them to customize the guest in an infinite number of ways: Installing software, changing logos and desktop backgrounds, adding user accounts, etc.

To use this, simply use the --firstboot option on the command line as many times as required:

$ virt-sysprep -a guest.img \
    --firstboot ./yum-update.sh \
    --firstboot ./set-desktop.sh

4 Comments

Filed under Uncategorized

New tool: virt-sysprep

New in libguestfs 1.13.19 is a tool called virt-sysprep which makes it easier to clone virtual machines.

The new tool isn’t a complete clone tool, but you can easily combine it with other tools like dd, the old virt-clone, virt-resize and virt-sparsify to clone virtual machines.

6 Comments

Filed under Uncategorized