Commit Graph

175 Commits

Author SHA1 Message Date
Kairui Song
69bf81bc8b Move watchdog detect and install code to module-setup.sh
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:40 +08:00
Kairui Song
08de712528 Move some dracut module dependencies checks to module-setup.sh
depend() in module-setup.sh is a better place to setup dracut module
dependency, it will do early check, and fail early if needed module is
missing. Also remove a unneeded helper add_dracut_module.

Also remove the unnecessary return in depend() function.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:19 +08:00
Kairui Song
a1664c63d0 mkdumprd: Ensure kdumpbase is added
Dracut only check if a module failed installtion if the module is listed
in --add params. Without this param, if kdumpbase failed to install due
to any reason, dracut will still build the initramfs only print a
warning. Add this param to ensure it fail early.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-11-05 01:10:14 +08:00
Lianbo Jiang
3b743ae6ae enable the logger for kdump
Since the logger was introduced into kdump, let's enable it for kdump
so that we can output kdump messages according the log level and save
these messages for debugging.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-10-27 17:33:54 +08:00
Kairui Song
5ec98c2ec7 mkdumprd: Improve the warning message when using encrypted target
Encrypted target have many issues, so let user check
kexec-kdump-howto.txt, which have more details.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-08-27 13:10:42 +08:00
Kairui Song
61d4fa72b5 mkdumprd: Improve the error message for umounted dump target
Since commit ca01cbd, mkdumprd can generate the initramfs even if dump
target is not mounted. But it will refuse to work if the dump target is
not marked as noauto, and not mounted.

If a target is not marked as noauto in fstab, it should be mounted
automatically on boot. If it's not mounted, most likely something is
wrong and user should fix that. So mkdumprd will just show an error
message and quit to avoid further failure.

This commit make the error message more clear and less confusing.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-06-24 14:15:49 +08:00
Kairui Song
807f0b5e48 mkdumprd: Fix nfs detection in to_mount
If target is in format of UUID= or LABEL=, current code will fail as it
expects target to be the absoluta path to the block device. Check for
the fstype instead.

Also simplify the code logic.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-06-23 09:34:53 +08:00
Kairui Song
a29de38da5 Always wrap up call to dracut get_persistent_dev function
Dracut get_persistent_dev function don't recognize UUID= or LABEL=
format, so caller should conver it to the path to the block device
before calling it. There is already such a helper
"kdump_get_persistent_dev", just move it to kdump-lib.sh and rename
it to reuse it,

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-06-22 19:58:08 +08:00
Kairui Song
5d4a5896c9 mkdumprd: Fix dracut error on multiple extra_modules
Dracut expects --add-drivers with a single parameter, so mkdumprd
should quota the module list.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-06-15 17:42:35 +08:00
Kairui Song
73da3224be Fix an error in commit ca01cbd
Previous commit ca01cbd ('mkdumprd: generate usable kdump initramfs
even target is not mounted') applied a wrong version of patch, let me
just fix it.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-05-22 19:29:19 +08:00
Kairui Song
ca01cbdfd5 mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.

So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.

When a mounted user configured target is used, the behavior is not
changed.

When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.

If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.

If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.

When path based target is used, there is no behavior change.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-22 16:14:07 +08:00
Kairui Song
61e016939c User get_mount_info to replace findmnt calls
Use get_mount_info so that fstab is used as a failback when look for
mount info.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-22 16:14:02 +08:00
Kairui Song
0624148414 Add a is_mounted helper
Use is_mounted helper instaed of calling findmnt directly or checking if
"mount" value is empty.

If findmnt looks for fstab as well, some non mounted entry will also
return value. Required to support non-mounted target.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-22 16:13:24 +08:00
Kairui Song
43ea36b3e8 Introduce get_kdump_mntpoint_from_target and fix duplicated /
User a helper to get the path to mount dump target in kdump kernel, and
fix duplicated '/' in the mount path problem.

Fixes: bz1785371
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-05-22 16:13:02 +08:00
Kairui Song
539bff4083 Append both nofail and x-systemd.before to kdump mount target
By this point, there is still an unresolved vfs kernel issue that blocks
systemd from mounting the dump target properly from time to time. To
prevent systemd from failing by mounting the dump target, we can add
nofail option to the kdump mount point.

But adding nofail will wipe out default dependency of the mount point,
see commit 94a7b43, so systemd randomize the order of calling kdump.sh
and mounting the dump target and lead to unexpected behavior.
However we can use x-systemd.before to ensure the mount is done
in right order.

In dracut-kdump-capture.service, we have "After=initrd.target",
and look at dracut.bootup.7, systems start processing of fstab by
initrd-fs.target, so set "After=initrd.target" could ensure the mount
is ready before pre-pivot and kdump-capture service.

Now with both nofail and x-systemd.before=initrd.target, systemd
will try to mount the dump target before calling kdump, and even if the
mount failed, kdump.sh will still be called and try to mount again. See
dump_fs function, which will try to mount if the target is not mounted.
Kdump will only fail if both mount attemp fails.

Else if the kdump target mount failed or unstable, systemd will directly
jump to kdump failure action, and kdump fails.

This should improve the robustness in general with no other risk.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-15 17:17:27 +08:00
Kairui Song
b82c35c842 Partially Revert "Don't mount the dump target unless needed"
This partially reverts commit 6dee286467.

There are reports that NFSv3 is failing after this commit, and after
more debug, I found NFSv4 may not work properly if
"nfs4_disable_idmapping" is set to 0.

The cause of the failure is that kdump.sh runs after dracut's pre-pivot
and clean up hook, many dracut module will install hooks to kill some
running services, so if the dump target requires a service to be running
but it's killed, mount will fail.

Dracut ensures the configured mount points are ready before pre-pivot.
After pre-pivot, any further mounting operation may not work as expected.

Although there is no report of other type of dump target failure except
NFSv3, it's better to revert this, to avoid other potential risk, and wait
for a proper fix for that systemd/kernel issue.

Else, this may bring more trouble for further development.

But still keep the change in kdump-lib-initramfs.sh for better
robustness.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-11 14:22:22 +08:00
Kairui Song
bde4b7af3b No longer treat atomic/silverblue specially
This commit remove almost all special workaround for atomic, and treat
all bind mounts in any environment equally.

Use a helper get_bind_mount_directory_from_path to get the bind mount
source path of given path.

is_atomic function now only used to determine the right /boot path
for atomic/silverblue environment.

And remove get_mntpoint_from_path(), it's the only function that never
ignore bind mount, and it have no caller after this clean up.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:37 +08:00
Kairui Song
b5b0b90521 mkdumprd: Simplify handling of user specified target
For user specified target, the config value is used as the dump target,
and SAVE_PATH (path in kdump.conf) value is used as the dump path within
the dump target, no need to do anything extra with the path value.

Current code logic is not only complicated, it also wrongly generate
an redundantly long path in atomic/silverblue environment.

The right way is only check two things, and do nothing else:

 1. The path exists within the target;
 2. The target is large enough to hold to contain the vmcore.

Currently checking the target still requires it to be mounted so it will
error out if it's not mounted. Will implement some auto mount as next
step.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:28 +08:00
Kairui Song
fd7e7be483 mkdumprd: Use get_save_path instead of parsing config
get_save_path provides default value fail back and error check, no need
to repeat it again.

Also remove a redundant echo and grep in get_save_path

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:07 +08:00
Bhupesh Sharma
760beb7e57 mkdumprd: Use DUMP_TARGET which printing error message during ssh
When building kdump initramfs for a SSH dump target, mkdumprd would
check whether it has the write permission on the SSH Server's
$DUMP_TARGET.

However $DUMP_TARGET is missing in the actual error message when the
user doesn't not have the write permission. For example:

 # kdumpctl restart
   kexec: unloaded kdump kernel
   Stopping kdump: [OK]
   Could not create temporary directory on :/home/bhsharma/test. Make
   sure user has write permission on destination
   mkdumprd: failed to make kdump initrd
   Starting kdump: [FAILED]

This patch using $1 value passed to mkdumprd, to print the
$DUMP_TARGET inside mkdir_save_path_ssh() function to
fix the issue.

Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-03-18 14:28:41 +08:00
Kazuhito Hagio
a1c28126ef mkdumprd: Use makedumpfile --check-params option
In order to check whether the specified makedumpfile parameters are
valid or not when generating initramfs, use the --check-params option,
which was recently added.

With the patch, kdumpctl can point out mistakes in core_collector
option and failed.  For example, if there is an practical mistake
that dump_level is -1:

  # cat /etc/kdump.conf
  core_collector makedumpfile -l --message-level 1 -d -1

  # kdumpctl start
  Detected change(s) in the following file(s):

    /etc/kdump.conf
  Rebuilding /boot/initramfs-5.4.19-200.fc31.x86_64kdump.img
  Dump_level(-1) is invalid.
  makedumpfile parameter check failed.
  mkdumprd: failed to make kdump initrd
  Starting kdump: [FAILED]

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-03-12 23:32:22 +08:00
Kairui Song
68dcfcfb47 mkdumprd: Fix dracut args parsing
Previous commit f13eab6 ('mkdumprd: simplify dracut args parsing')
break dracut arguments parsing for some use case, this should fix it
well.

Passed nfs/local/iscsi/ssh dump test, and with extra dracut_argss.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-12-27 12:29:43 +08:00
Kairui Song
f13eab60cb mkdumprd: simplify dracut args parsing
Previously dracut_args is stored as an array in the shell code,
so we can just pass this array as argument to dracut.
But when trying to append new dracut argument, we have to manually
handle the quotes and spaces to ensure the appended argument is
splitted into array elements in the right way.

This is complex and hard to read or maintain. Instead, just store the
dracut_args as a plain string, and let xargs help parse it and call
dracut.

Simply passing $dracut_args or "$dracut_args" will either let dracut
consider the whole string as a single argument, or loss all the
quotes. xargs can handle it well and cover more corner cases.

Eg. one corner case before, if we have:
dracut_args --mount "/dev/sda1 /mnt/test xfs rw"

Kdump will fail, because the function add_dracut_arg() will wrongly
change the arguments into: (Notice the extra space.)
dracut_args --mount " /dev/sda1 /mnt/test xfs rw"

Instead of fixing it just use xargs instead. Tested with above config
and multiple other dracut_args values.

Resolves: bz1700136
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-11-27 23:45:54 +08:00
Kairui Song
18ee888eab mkdumprd: ensure ssh path exists before check size
check_size checks if the specified dump path on the ssh target have
enough space. And if the path doesn't exits, it will fail and exit.

mkdir_save_path_ssh should be called first to check if the path
exists, and create the path if it doesn't exits, so the size check
can always work properly.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-10-24 16:59:22 +08:00
Kairui Song
6dee286467 Don't mount the dump target unless needed
For fadump, this helps to reduce the risk of boot failure, and
may also help speed up the boot by a bit.

For normal kdump, this will delay the dump target mounting, and no
longer depend on systemd to do the mounting job.

And currently there is a failure that caused by some mount handling
bug with kernel and systemd that is failing the system booting:

[FAILED] Failed to mount /kdumproot/home.
See 'systemctl status kdumproot-home.mount' for details.
[DEPEND] Dependency failed for Local File Systems.
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Remote File Systems.
         Starting udev Coldplug all Devices...
         Starting Create Volatile Files and Directories...
         Starting Kdump Emergency...

This patch can bypass it. The fix of root cause is still WIP, but this
patch itself is a nice to have optimization so it's reasonable to do so.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-09-29 17:12:54 +08:00
Kairui Song
75d9132417 Get rid of duplicated strip_comments when reading config
When reading kdump configs, a single parsing should be enough and this
saves a lot of duplicated striping call which speed up the total load
speed.

Speed up about 2 second when building and 0.1 second for reload in my
tests.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-05-20 16:56:28 +08:00
Kairui Song
289e16c881 mkdumprd: Improve the config reading logic
Seems some dead codes are left here for historical reason, just remove
them, read the config and strip comments only for once.

This improve the speed by a lot (2.6s -> 0.498s for reading a
simple config in my test case, on HDD) and make the code cleaner.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-03-29 10:52:39 +08:00
Kairui Song
05cec1657f mkdumprd: refine regex on dropping mount options
Currently we use "\b" (word boundary) as the delimiter for ro option,
which is not correct. For mount options like
"defaults,errors=remount-ro" the ro on the tail will also be replaced
and result in an invalid mount option.

So we use a more strict logic on detecting ro mount option. It should
either starts with "," or "^" (begin of line) and ends with "," or "$"
(end of line), and keep the delimiter untouched. This should ensure
only valid mount option got detected and replaced.

This passed following tests:

defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro,
defaults,errors=remount-ro => defaults,errors=remount-ro
defaults,ro,relatime => defaults,rw,relatime
defaults,ro => defaults,rw

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-01-28 18:23:03 +08:00
Kairui Song
0c24dce730 mkdumprd: force drop earlykdump module
earlykdump is not suppose to be loaded for a kdump initramfs, and user
may add it into dracut's config file so it will be included by default.
It will also make the image building always fail because earlykdump
actually detect if it's being used for kdump image and raise an error if
so.

In that case, we always force drop this module to avoid such problem.

Signed-off-by: Kairui Song <ryncsn@gmail.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-01-10 18:18:45 +08:00
Kazuhito Hagio
2310616572 mkdumprd: allow spaces after 'path' config phrase with network dump setting
Without this patch, when there are two or more spaces after 'path'
configuration phrase with ssh or nfs setting, SAVE_PATH is set to
'/var/crash' in mkdumprd, and in most cases kdump service fails to
start by checking the /var/crash directory regardless of the path
value.

  ssh kdump(a)192.168.122.1
  path  /kdump
      ^^

This behavior would be too sensitive and different from the other
configurations. With this patch, mkdumprd allows such spaces.

Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com&gt;
Acked-by: Kairui Song <kasong@redhat.com>
2019-01-08 18:26:14 +08:00
Kairui Song
d4f04afa47 mkdumprd: drop some nfs mount options when reading from kernel
nfs service will append extra mount options to kernel mount options.
Those extra options represent current mounting details, but they may
not suitable for the second kernel. IP address may change, and we only
enable a single network stack (v4/v6), if nfs prefered another
network stack, inheriting the options will force nfs service to use
previous network stack and disable nfs's fallback mechanic and fail.

As nfs service have the capability to negotiate required protocols
and detect proper IP address, just drop those options and let nfs
automatically adapt the possible change in the second kernel.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2018-11-24 17:48:49 +08:00
Kairui Song
94a7b43407 Always drop nofail or nobootwait options
If nofail or nobootwait option is used, systemd's local-fs.target won't
wait for the mounting to complete, and kdump might start before the
required mount point is ready and then fail.

The host might use nofail for reasons like the device may get unpluged,
and if the device is not mounted and it is set as kdump target as the same
time then kdump service won't start, we will never enter the capture
kernel. By the time we have entered the capture kernel, the target device
must exist and ready to use, or else kdump would fail anyway. So force
remove nofail and nobootwait option.

Also drop rootflags=nofail option, as we don't depend on rootfs anymore
if the dump target don't required it. So the nofail option is no longer
needed.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2018-08-14 10:34:45 +08:00
Kairui Song
4eedcae5e1 dracut-module-setup.sh: don't include multipath-hostonly
This commit basically reverts commit c755499fad,
and make use of new introduced tri-state hostonly mode.

Following dracut commits merged multipath-hostonly into multipath
module, and introduced a tri-state hostonly mode.

    commit 35e86ac117acbfd699f371f163cdda9db0ebc047
    Author: Kairui Song <kasong@redhat.com>
    Date:   Thu Jul 5 16:20:04 2018 +0800

        Merge 90-multipath-hostonly and 90-multipath

    commit a695250ec7db21359689e50733c6581a8d211215
    Author: Kairui Song <kasong@redhat.com>
    Date:   Wed Jul 4 17:21:37 2018 +0800

        Introduce tri-state hostonly mode

multipath-hostonly module was introduced only for kdump, because kdump
need a more strict hostonly policy for multipath device to save memory.

Now multipath module will provide the behave we wanted by setting
hostonly mode to strict.
2018-07-26 19:25:09 +08:00
Dave Young
d3577e3394 Revert "Use absolute path /usr/bin/dracut in mkdumprd"
This reverts commit 8e3b6475c9.

After reading the background of bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1510922

It is not a problem actually, sorry for the noise.

Although root set different "PATH" can lead to wrong script, but it is
different with what the bug described "current working dir" and it is
not a problem worth an update
2017-11-09 15:29:22 +08:00
Dave Young
8e3b6475c9 Use absolute path /usr/bin/dracut in mkdumprd
Since we call dracut directly on current working directory "." so it is
possible to trick root to call fake code.

Thus move to use absolute path instead.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Bhupesh Sharma <bhsharma@redhat.com>
2017-11-09 13:46:13 +08:00
Dave Young
69ba16a409 mkdumprd: use --quiet dracut argument to speedup initramfs build
Currently in Fedora/RedHat dracut installs its fedora.conf.example
as the default config file, in which sysloglvl is set 5. This leads
to maxloglvl=5 in dracut calls, making unnecessary lsinitrd calls
during initramfs builds by kdump.

This patch makes use of
https://github.com/dracutdevs/dracut/pull/272
and disables lsinitrd logging by giving "-q" option to dracut,
eliminating unnecessary lsinitrd calls in dracut.

1) Before this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.0-0.rc1.git4.1.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real    0m26.824s
user    0m9.958s
sys     0m15.106s

2) After this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.0-0.rc1.git4.1.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real    0m20.420s
user    0m8.385s
sys     0m10.468s

[dyoung]:
- rewrite patch subject

Signed-off-by: Ziyue Yang <ziyang@redhat.com>
Reviewed-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:42:31 +08:00
Dave Young
75ab9ee26a mkdumprd: fix patterns to modify mount options
mkdumprd removes "noauto" mount option, but it also mistakenly removes
"noauto" within a string. For example ext4 has mount option noauto_da_alloc
mkdumprd will replace it with _da_alloc.

Use '\b' to match a whole word of "noauto" to fix it.
Also do same for s/ro/rw for same reason.

Signed-off-by: Dave Young <dyoung@redhat.com>
Reveiwed-by: Xunlei Pang <xlpang@redhat.com>
2017-09-06 15:42:24 +08:00
Xunlei Pang
e067d77dfc mkdumprd: apply dracut "--hostonly-cmdline" and "--no-hostonly-default-device"
Dracut has "--hostonly-cmdline" which can generate cmdlines(if any)
regarding the dump target, it's an existing way for us to use to
simplify the code. E.g. We already removed generate_lvm_cmdlines(),
to use "--hostonly-cmdline".

But "--hostonly-cmdline" has other issues(e.g. BZ1451717), it adds
needless devices for kdump like root device.

Now dracut supports "--no-hostonly-default-device" which enables
us to only add the kdump target, which can avoid needless devices
being recognized under kdump. Thus "--hostonly-cmdline" side effects
can be avoided with the help of "--no-hostonly-default-device".

This patch applies dracut's "--hostonly-cmdline" together with
"--no-hostonly-default-device" to achieve above-mentioned purpose.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:40:04 +08:00
Xunlei Pang
31dc60ad20 Change dump_to_rootfs to use "--mount" instead of "root=X"
Currently, we kept "root=X" for the dump_to_rootfs case, this
patch consolidates to use "--mount" for all the kdump mounts.

One advantage of this way is that dracut can correctly mark root
(in case of dump_to_rootfs is specified) as the host device when
"--no-hostonly-default-device" is added in the following patch.

Changed the code style in passing, as shellcheck tool reported:
Use $(..) instead of deprecated `..`

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:39:41 +08:00
Xunlei Pang
8250f23c10 Revert "mkdumprd: omit crypt when there is no crypt kdump target"
This reverts commit 54a5bcc4ee.

We are going to add "--no-hostonly-default-device" dracut argument
in the following patch.

With the help of "--no-hostonly-default-device", dracut only
adds the dump target as host devices, which naturally guarantees
only required dracut modules being selected.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:38:09 +08:00
Xunlei Pang
dcffd4759e Revert "mkdumprd: omit dracut modules in case of no dm target"
This reverts commit 821d1af080.

We are going to add "--no-hostonly-default-device" dracut argument
in the following patch.

With the help of "--no-hostonly-default-device", dracut only
adds the dump target as host devices, which naturally guarantees
only required dracut modules being selected.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:37:45 +08:00
Xunlei Pang
2c9128a971 Revert "mkdumprd: omit dracut modules in case of network dumping"
This reverts commit fb522e972c.

We are going to add "--no-hostonly-default-device" dracut argument
in the following patch.

With the help of "--no-hostonly-default-device", dracut only
adds the dump target as host devices, which naturally guarantees
only required dracut modules being selected.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:37:15 +08:00
Xunlei Pang
8fd9f017b2 mkdumprd: remove useless "x-initrd.mount"
After the following systemd commit, "x-initrd.mount"
option became useless actually, we can safely remove
it now.

commit ce3f6d82b003f365f718f24e48f55b8a0372b924
Author: nmartensen <nis.martensen@web.de>
Date:   Fri Jan 15 07:55:25 2016 +0100

    fstab-generator: remove bogus condition

    The sysroot mount is already taken care of by the
    add_sysroot_mount function. With this condition
    left in, we can we can get something like this:

    initrd-root-fs.target.requires
    `-- usr.mount -> /run/systemd/generator/usr.mount

    in the main system (i.e., not in the initramfs). In
    the initramfs, the previous condition already kicks in.

[snip]

"mount_in_initrd(me)" is true with "x-initrd.mount" option,
the behaviour of systemd fstab generator changed after the
above-mentioned patch, it always generates local mount units
required by local-fs.target regardless of "x-initrd.mount".

After failure, it enters dracut emergency, further triggers
kdump emergency service, thus there is no problem.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-19 09:51:12 +08:00
Xunlei Pang
fb522e972c mkdumprd: omit dracut modules in case of network dumping
In case of only network target, we can clearly and safely
remove more unnecessary modules to reduce initramfs size,
and to enhance stability.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:48 +08:00
Xunlei Pang
821d1af080 mkdumprd: omit dracut modules in case of no dm target
In case of on dm related target, we can clearly and safely
remove many unnecessary modules to reduce initramfs size,
and to enhance stability.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:40 +08:00
Xunlei Pang
54a5bcc4ee mkdumprd: omit crypt when there is no crypt kdump target
Resolves: bz1451717
https://bugzilla.redhat.com/1451717

When there is no crypt related kdump target, we can safely
omit "crypt" dracut module, this can avoid the pop asking
disk password during kdump boot in some cases.

This patch introduces omit_dracut_modules() before calling
dracut, we can omit more modules to reduce initrd size in
the future.

We don't want to omit any module for fadump, thus we move
is_fadump_capable() into kdump-lib.sh as a helper to use.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:31 +08:00
Xunlei Pang
9e7b64dc90 mkdumprd: change for_each_block_target() to use get_kdump_targets()
Resolves: bz1451717
https://bugzilla.redhat.com/1451717

Now that we have get_kdump_targets(), use it to simplify the code.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:15 +08:00
Xunlei Pang
3ee00cd384 kdump-lib.sh: introduce get_kdump_targets()
Resolves: bz1451717
https://bugzilla.redhat.com/1451717

We need to know all the kdump targets including the dump
target and root in case of "dump_to_rootfs".

This is useful for us to do some extra work related to the
type of different targets.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:06 +08:00
Xunlei Pang
1bc78e025f kdump-lib.sh: fix improper get_block_dump_target()
Resolves: bz1451717
https://bugzilla.redhat.com/1451717

This patch improves get_block_dump_target as follows:
-Consider block device in the special "--dracut-args --mount ..."
 in get_user_configured_dump_disk().
-Consider save path instead of root fs in get_block_dump_target(),
 and move it into kdump-lib.sh because we will have another user
 in the following patch.
-For nfs/ssh dumping, there is no need to check the root device.
-Move get_save_path into kdump-lib.sh.

After this patch, get_block_dump_target() can always return the
correct block dump target specified.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:53:43 +08:00
Xunlei Pang
b40c1f96cf kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.

For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.

This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).

After removing "root=X", we now add root fs mount information
explicitly from the kdump side.

Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-11 16:02:12 +08:00