[Libguestfs] [PATCH 8/8] v2v: linux: correctly reconfigure the initrd on Debian
Tomáš Golembiovský
tgolembi at redhat.com
Wed Aug 10 12:00:57 UTC 2016
On Wed, 10 Aug 2016 11:05:19 +0200
Pino Toscano <ptoscano at redhat.com> wrote:
> On Tuesday, 9 August 2016 13:55:53 CEST Tomáš Golembiovský wrote:
> > On Mon, 8 Aug 2016 18:38:55 +0200
> > Pino Toscano <ptoscano at redhat.com> wrote:
> >
> > > Use the canonical way to regenerate the initrd images for all the
> > > installed kernels, i.e. reconfigure the initramfs-tools which will
> > > trigger the kernel postinst scripts.
> > > ---
> > > v2v/convert_linux.ml | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
> > > index cfe46b8..a556ce6 100644
> > > --- a/v2v/convert_linux.ml
> > > +++ b/v2v/convert_linux.ml
> > > @@ -866,7 +866,9 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
> > > ignore (g#command (Array.of_list args))
> > > in
> > >
> > > - if g#is_file ~followsymlinks:true "/sbin/dracut" then
> > > + if family = `Debian_family then
> > > + ignore (g#command ([| "dpkg-reconfigure"; "--frontend=noninteractive"; "initramfs-tools" |]))
> > > + else if g#is_file ~followsymlinks:true "/sbin/dracut" then
> > > run_dracut_command "/sbin/dracut"
> > > else if g#is_file ~followsymlinks:true "/usr/bin/dracut" then
> > > run_dracut_command "/usr/bin/dracut"
> >
> > It might be better to call update-initramfs directly. I don't know, is
> > using dpkg-reconfigure maybe safer across distributions? The slight
> > advantage of calling update-initramfs is that we can turn on verbose
> > mode, just like for dracut:
> >
> > let run_update_initramfs_command () =
> > let args =
> > "update-initramfs" ::
> > (if verbose () then [ "-v" ] else [])
> > @ [ "-c"; "-k"; mkinitrd_kv ]
> > in
> > ignore (g#command (Array.of_list args))
> > in
> >
> > The other advantage is that we can provide the kernel version we want.
> > The default is to update the initramfs for the latest kernel, which in
> > theory might not be the one we want if it were missing virtio drivers
> > (not sure if this can happen). According to ordering we do any kernel
> > without virtio drivers is worse than any kernel with virtio drivers.
>
> Makes sense, I'll drop my patch and leave it to you.
>
Ok.
> > What we can also do is specify list of modules we require. Similar to
> > what we do for dracut/mkinitrd. Debian uses a file for that:
> >
> > (* The modules to add to initrd are defined in a file. *)
> > ignore (g#sh "sh -c 'echo \\# Added by virt-v2v >> /etc/initramfs-tools/modules'");
> > let cmd = (sprintf "sh -c 'echo %s >> /etc/initramfs-tools/modules'"
> > (String.concat " " modules)) in
> > ignore (g#sh cmd);
>
> If we want to do that, then please use the write_append API for this.
Yes, that's much better. Thanks for the tip.
--
Tomáš Golembiovský <tgolembi at redhat.com>
More information about the Libguestfs
mailing list