From a74225f763b77b29024737ba027a2094e00d8842 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Thu, 22 Dec 2022 13:28:43 +0800 Subject: [PATCH] fadump: preserve file modification time to help with hardlinking Resolves: bz2139000 Upstream: Fedora Conflict: None commit f33c99e34749e976b610ad939f507cc471b33980 Author: Hari Bathini Date: Mon Oct 31 15:42:21 2022 +0530 fadump: preserve file modification time to help with hardlinking With commit fa9201b2 ("fadump: isolate fadump initramfs image within the default one"), initramfs image gets to hold two images, one for production kernel boot purpose and the other for capture kernel boot. Most files are common among the two images. Retain file modification time to replace duplicate files with hardlinks and save space. Also, avoid unnecessarily compressing fadump image that is decompressed immediately anyway. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo Signed-off-by: Lichen Liu --- mkfadumprd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mkfadumprd b/mkfadumprd index 1e09ac2..36ad645 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -40,14 +40,16 @@ touch "$MKFADUMPRD_TMPDIR/fadump.initramfs" ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER" # Don't use squash for capture image or default image as it negatively impacts # compression ratio and increases the size of the initramfs image. -if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash; then +# Don't compress the capture image as uncompressed image is needed immediately. +# Also, early microcode would not be needed here. +if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --no-compress --no-early-microcode; then perror_exit "mkfadumprd: failed to build image with dump capture support" fi -### Unpack the initramfs having dump capture capability +### Unpack the initramfs having dump capture capability retaining previous file modification time. +# This helps in saving space by hardlinking identical files. mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" -if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && - popd > /dev/null); then +if ! cpio -id --preserve-modification-time --quiet -D "$MKFADUMPRD_TMPDIR/fadumproot" < "$FADUMP_INITRD"; then derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" exit 1 fi