On Friday, 16 September 2016 13:10:37 CEST Tomáš Golembiovský wrote:
Using update-initramfs is the native way of updating initrd on
Debian
based systems.
To add some modules to the image we can list them in file
/etc/initramfs-tools/modules.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/convert_linux.ml | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 08f4b2a..22a7919 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,30 @@ 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;
+
+ if List.length modules > 0 then (
+ (* The modules to add to initrd are defined in:
+ * /etc/initramfs-tools/modules
+ * File format is same as modules(5).
+ *)
+ let file = "/etc/initramfs-tools/modules" in
+ let path = sprintf "/files%s" file in
IMHO you can avoid this help variable, and just write "/files" directly
in the two places below.
+ g#aug_transform "modules" file;
+ g#aug_load ();
Use Linux.augeas_init here -- it's roughly the same, but it logs Augeas
errors.
+ g#aug_set (sprintf "%s/#comment[last()+1]"
path)
+ "The following modules were added by virt-v2v";
+ List.iter (
+ fun m -> g#aug_clear (sprintf "%s/%s" path m)
+ ) modules;
You can use currying here:
List.iter (g#aug_clear (sprintf "/files%s/%s") file) modules;
With the above files, LGTM.
Thanks,
--
Pino Toscano