From d1f3be0eedeac294a79f4aeb12450d73c08c55d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 27 Feb 2018 23:19:50 +0100 Subject: [PATCH] kernel-install: avoid creating initramfs multiple times There are multiple places where initramfs can be created: - /boot/iniramfs-*.img - /boot/$MACHINE_ID/.../initrd (unused on Qubes, but created by Fedora scripts) - /boot/efi/EFI/.../initramfs-*.img Do not generate all of those from scratch, but try to reuse existing image (if exists). Since one dracut call may last even 5 minutes, this change should greatly reduce installation time. Fixes QubesOS/qubes-issues#3637 --- system-config/kernel-grub2.install | 9 ++++++++- system-config/kernel-xen-efi.install | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/system-config/kernel-grub2.install b/system-config/kernel-grub2.install index 71f0a36..466e637 100755 --- a/system-config/kernel-grub2.install +++ b/system-config/kernel-grub2.install @@ -2,10 +2,17 @@ COMMAND="$1" KVER="$2" +BOOT_DIR_ABS="$3" case "$COMMAND" in add) - dracut -f "/boot/initramfs-${KVER}.img" "$KVER" + if [ ! -e "/boot/initramfs-${KVER}.img" ]; then + if [ -e "$BOOT_DIR_ABS"/initrd ]; then + cp "$BOOT_DIR_ABS"/initrd "/boot/initramfs-${KVER}.img" + else + dracut "/boot/initramfs-${KVER}.img" "$KVER" + fi + fi ;; remove) rm -f "/boot/initramfs-${KVER}.img" diff --git a/system-config/kernel-xen-efi.install b/system-config/kernel-xen-efi.install index 842eac3..005dd18 100755 --- a/system-config/kernel-xen-efi.install +++ b/system-config/kernel-xen-efi.install @@ -77,7 +77,11 @@ case "$COMMAND" in fi cp "/boot/vmlinuz-$KVER" "$EFI_DIR/" - dracut -f "$EFI_DIR/initramfs-${KVER}.img" "$KVER" + if [ -e "/boot/initramfs-${KVER}.img" ]; then + cp -f "/boot/initramfs-${KVER}.img" "$EFI_DIR/" + else + dracut -f "$EFI_DIR/initramfs-${KVER}.img" "$KVER" + fi ;; remove) # don't care about changing default= line - yum should prevent removing