On Fri, Feb 5, 2021 at 9:32 PM piliu <piliu(a)redhat.com> wrote:
On 2/5/21 6:10 PM, Kairui Song wrote:
> On Thu, Feb 4, 2021 at 10:02 AM Kairui Song <kasong(a)redhat.com> wrote:
>>
>> Currently kdump simply uses dracut and pulls all the required binaries
>> from the host directly. This keep things simple as kdump is using same
>> binaries and libs from the system of fisrt kernel.
>>
>> But some binaries, like systemd, is growing too large, which increase
>> the memory usage by a lot, and most of its features are never used
>> in kdump. So it's more reasonable to use a rebuilt-minimized version.
>>
>> So for such binaries, introduce a "build root" overlay here. Before
>> calling dracut to build initramfs, setup an overlay to let the build
>> root override current rootfs, so dracut can just work as usual, but the
>> binaries used are from the "build root".
>>
>> All binaries/libs that need to be rebuild for smaller size can be put in
>> the build root.
>
> Oh, I forgot to mention, the custom binaries are suppose to be
> provided by other packages and installed in /usr/lib/kdump/buildroot
> An example package is `kdump-initrd-systemd`:
>
https://copr.fedorainfracloud.org/coprs/kasong/kexec-kdump-preview/packag...
>
Is there any systemd document whch can help us to check
CONFIGURE_OPTS_KDUMP in
https://github.com/ryncsn/kdump-initrd-systemd/blob/master/systemd.spec
Hi Pingfan, I didn't see any good reference with the systemd compile
options, you can run `meson configure` in the systemd code base to get
the config descriptions but these are only very brief summary.
I just turned off everything and then picked what is really required
for kdump, and tested with many different kinds of dump targets, all
seems to work well. We can update the config profile if we find
anything not working.
Thanks,
Pingfan
> It's a smaller recompile and repackaged version of systemd, using this
> package can reduce the memory usage by about 20MB.
>
>> ---
>> kexec-tools.spec | 1 +
>> mkdumprd | 20 +++++++++++++++++++-
>> 2 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/kexec-tools.spec b/kexec-tools.spec
>> index 91bc0f3..1a06b62 100644
>> --- a/kexec-tools.spec
>> +++ b/kexec-tools.spec
>> @@ -171,6 +171,7 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir}
>> mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir}
>> mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir}
>> mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump
>> +mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump/buildroot
>> install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl
>>
>> install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec
>> diff --git a/mkdumprd b/mkdumprd
>> index c34b79c..5f8d2da 100644
>> --- a/mkdumprd
>> +++ b/mkdumprd
>> @@ -23,6 +23,7 @@ if [ $? -ne 0 ]; then
>> exit 1
>> fi
>>
>> +KDUMP_BUILDROOT="/usr/lib/kdump/buildroot"
>> conf_file="/etc/kdump.conf"
>> SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
>> SAVE_PATH=$(get_save_path)
>> @@ -33,12 +34,14 @@ dracut_args="--add kdumpbase --quiet --hostonly
--hostonly-cmdline --hostonly-i1
>>
>> readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
>> [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d
-t dracut.XXXXXX failed."
>> +readonly MKDUMPRD_TMPROOT="$MKDUMPRD_TMPDIR/root"
>> readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
>>
>> trap '
>> ret=$?;
>> is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
>> [[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf --
"$MKDUMPRD_TMPDIR";
>> + [[ -d $MKDUMPRD_TMPROOT ]] && rm --one-file-system -rf --
"$MKDUMPRD_TMPROOT";
>> exit $ret;
>> ' EXIT
>>
>> @@ -460,7 +463,22 @@ if ! is_fadump_capable; then
>> add_dracut_arg "--no-hostonly-default-device"
>> fi
>>
>> -echo "$dracut_args $@" | xargs dracut
>> +if [ -n "$(ls -A1 $KDUMP_BUILDROOT | grep -E "etc|usr")" ];
then
>> + # Run in a new namespace, so overlay on root is safe
>> + # everything is automatically cleaned up upon exit
>> + export KDUMP_BUILDROOT
>> + export MKDUMPRD_TMPROOT
>> + export dracut_args="$dracut_args $@"
>> +
>> + cp -r /usr/lib/kdump/buildroot $MKDUMPRD_TMPROOT
>> + unshare --mount bash -c '
>> + for _d in etc usr; do
>> + [ -d "$MKDUMPRD_TMPROOT/$_d" ] && mount overlay -t
overlay -o ro,lowerdir=$MKDUMPRD_TMPROOT/$_d:/$_d /$_d;
>> + done
>> + echo "$dracut_args $@" | xargs -t dracut;'
>> +else
>> + echo "$dracut_args $@" | xargs -t dracut
>> +fi
>>
>> _rc=$?
>> sync
>> --
>> 2.29.2
>>
>
>
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
--
Best Regards,
Kairui Song