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
This commit is contained in:
Marek Marczykowski-Górecki 2018-02-27 23:19:50 +01:00
parent 6cef3f3966
commit d1f3be0eed
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 13 additions and 2 deletions

View File

@ -2,10 +2,17 @@
COMMAND="$1" COMMAND="$1"
KVER="$2" KVER="$2"
BOOT_DIR_ABS="$3"
case "$COMMAND" in case "$COMMAND" in
add) 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) remove)
rm -f "/boot/initramfs-${KVER}.img" rm -f "/boot/initramfs-${KVER}.img"

View File

@ -77,7 +77,11 @@ case "$COMMAND" in
fi fi
cp "/boot/vmlinuz-$KVER" "$EFI_DIR/" 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) remove)
# don't care about changing default= line - yum should prevent removing # don't care about changing default= line - yum should prevent removing