On 08/30/2017 at 04:45 PM, Hari Bathini wrote:
On Wednesday 30 August 2017 07:14 AM, Xunlei Pang wrote:
> On 08/29/2017 at 09:45 PM, Hari Bathini wrote:
>> As default initrd is used for booting fadump capture kernel, it must be
>> rebuilt with dump capture capability when dump mode is fadump. Check if
>> default initrd is already fadump capable and rebuild, if necessary.
>>
>> Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
>> ---
>>
>> * Using `lsinitrd -f` over `lsinitrd -m`, to find if kdumpbase module
>> is included, as it is observed to take only about half the time.
>>
>>
> Hi Hari, could you please try the following approach?
>
> ---
> kdumpctl | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/kdumpctl b/kdumpctl
> index 12f360a..1a24d29 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -313,7 +313,7 @@ check_executable()
> backup_default_initrd()
> {
> if [ ! -f "$DEFAULT_INITRD" ]; then
> - return
> + return 1
> fi
>
> if [ ! -e $DEFAULT_INITRD_BAK ]; then
> @@ -324,8 +324,12 @@ backup_default_initrd()
> if [ $? -ne 0 ]; then
> echo "WARNING: failed to backup $DEFAULT_INITRD."
> rm -f $DEFAULT_INITRD_BAK
> + return 1
> fi
> + return 0
> fi
> +
> + return 1
> }
>
> restore_default_initrd()
> @@ -345,9 +349,12 @@ restore_default_initrd()
> echo -n "Restoring original initrd as fadump mode "
> echo "is disabled."
> sync
> + return 0
> fi
> fi
> fi
> +
> + return 1
> }
>
> check_config()
> @@ -717,9 +724,9 @@ check_rebuild()
> system_modified="1"
> fi
>
> - handle_mode_switch
> -
> - if [ $image_time -eq 0 ]; then
> + if handle_mode_switch; then
> + echo -n "Dump mode changed from last boot."; echo
> + elif [ $image_time -eq 0 ]; then
> echo -n "No kdump initial ramdisk found."; echo
> elif [ "$force_rebuild" != "0" ]; then
> echo -n "Force rebuild $TARGET_INITRD"; echo
> @@ -886,12 +893,12 @@ handle_mode_switch()
> if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
> # backup initrd for reference before replacing it
> # with fadump aware initrd
> - backup_default_initrd
> + return backup_default_initrd
> else
> # check if a backup of default initrd exists. If yes,
> # it signifies a switch from fadump mode. So, restore
> # the backed up default initrd.
> - restore_default_initrd
> + return restore_default_initrd
> fi
> }
>
I am apprehensive about this approach, as it may not add kdumpbase to default initrd
again,
if it has been changed outside kdumpctl script (after initrd is backed up).
OK, then let's return back to your approach :-)
Regards,
Xunlei