[Libguestfs] Can I update a specific package with virt-customize/virt-sysprep

Richard W.M. Jones rjones at redhat.com
Thu Dec 24 16:48:52 UTC 2015


On Thu, Dec 24, 2015 at 06:16:09PM +0200, Yaniv Kaul wrote:
> I'm using an image (Fedora cloud) which apparently doesn't have iSCSI
> kernel module available as-is. I therefore need to update kernel-core in
> order to get it.
> Is there a way I can do it via virt-sysprep / virt-customize?

I believe this _won't_ work as you probably discovered already:

  virt-customize -a cloud.img --install kernel-core

The --install flag runs 'dnf -y install', which means it just checks
that kernel-core is installed and stops if it is already installed.
(Whereas 'dnf -y install --best' tries to update the package to the
"best", ie highest, version).

For --update, that was fixed in commit 16e6378a5b4b2 (2015-08-04).
But we didn't change the behaviour of --install.  Perhaps we should.

If you have a particular package that you want to install, an
alternative would be something like:

  virt-customize -a cloud.img --install fedora-repos-rawhide --install https://kojipkgs.fedoraproject.org//packages/kernel/4.4.0/0.rc6.git1.1.fc24/x86_64/kernel-core-4.4.0-0.rc6.git1.1.fc24.x86_64.rpm

Assuming that you choose a package that exists in (guest) repos that
are already set up in the image, dnf will go and find any dependencies
automatically and update things to the version you requested.
Otherwise you could either list all dependencies on the virt-customize
command line (gets tedious quite quickly), or drop a repo file into
/etc/yum.repos.d/ using the virt-customize --write flag.  Or install
the correct repos package, which is what '--install fedora-repos-rawhide'
is doing above.

It helps to look at the code to see the command that gets run when you
use the --install (or other) option:

  https://github.com/libguestfs/libguestfs/blob/master/customize/customize_run.ml#L96

To run commands directly under your control, use --run-command.
Perhaps this is a better option?

  virt-customize -a cloud.img --run-command '
    dnf -y install --best kernel-core
  '

If you want everything to be super-controllable by you, including
making it work even if the network is down, then put the RPMs required
into an ISO and use the --attach + --run-command options.  Something
like this:

  genisoimage -o drivers.iso -V DRIVERS ... plus other parameters to make an ISO from your RPMs directory
  virt-customize -a cloud.img --attach drivers.iso --run-command '
      mkdir /tmp/mount
      mount LABEL=DRIVERS /tmp/mount
      dnf -y install --best /tmp/mount/path/to/my/drivers/*.rpm
  '

[I talk about RPMs above, but everything I said applies equally to
Debian/Ubuntu + dpkg, or other Linux distros.]

> I would like on the first boot already to use iSCSI (I'm using a script
> there to already login to a target, etc.), so first boot (+ it'll require
> an additional boot anyway) is too late for this.

Yes, if you need to boot with the driver, then you need to do an
offline install of some kind.  As you say --firstboot / cloud-init is
too late.  It's the same problem that virt-v2v has.

> Is there a way to do it, as it seem 'update' updates everything (and thus
> bloats my image a bit).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list