[Libguestfs] [PATCH v3 1/2] v2v: linux: correctly reconfigure the initrd on Debian

Richard W.M. Jones rjones at redhat.com
Tue Sep 13 14:29:42 UTC 2016


On Tue, Sep 13, 2016 at 03:51:13PM +0200, Tomáš Golembiovský wrote:
> Using update-initramfs is the native way of updating initrd on Debian
> based systems.
> 
> Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
> ---
>  v2v/convert_linux.ml | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
> index 08f4b2a..b09d03e 100644
> --- a/v2v/convert_linux.ml
> +++ b/v2v/convert_linux.ml
> @@ -478,6 +478,15 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
>          ignore (g#command (Array.of_list args))
>        in
>  
> +      let run_update_initramfs_command () =
> +        let args =
> +          "/usr/sbin/update-initramfs"  ::
> +            (if verbose () then [ "-v" ] else [])
> +          @ [ "-c"; "-k"; mkinitrd_kv ]
> +        in
> +        ignore (g#command (Array.of_list args))
> +      in
> +
>        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
> @@ -491,6 +500,18 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
>                         "-k"; kernel.ki_vmlinuz |]
>          )
>        )
> +      else if family = `Debian_family then (
> +        if not (g#is_file ~followsymlinks:true "/usr/sbin/update-initramfs") then
> +          error (f_"unable to rebuild initrd (%s) because update-initramfs was not found in the guest")
> +            initrd;
> +
> +        (* The modules to add to initrd are defined in a file. *)
> +        let modules = String.concat "\n" modules in
> +        let modules = "#\n# Added by virt-v2v\n" ^ modules ^ "\n" in
> +        ignore (g#write_append "/etc/initramfs-tools/modules" modules);

I suspect this won't work if the file doesn't already end with a \n

Rich.

> +        run_update_initramfs_command ()
> +      )
>        else if g#is_file ~followsymlinks:true "/sbin/mkinitrd" then (
>          let module_args = List.map (sprintf "--with=%s") modules in
>          let args =
> -- 
> 2.9.3
> 
> 
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list