[PATCH RFC] module-setup.sh: install usb serial driver for ttyUSB0
by Dave Young
In case one want to use usb serial console, we need to pack the usb serial
driver into kdump initramfs so that one can see the console output on the usb
console.
I only handled ttyUSB0, this is like a hard code, but it should be enough for
most cases. Also only install the driver for the ttyUSB0 device.
Tested with adding "console=ttyUSB0" in 2nd kernel commandline.
Tested latest F22 kernel, there's CONFIG_USB_SERIAL_CONSOLE=y, kdump work ok.
Signed-off-by: Dave Young <dyoung(a)redhat.com>
---
dracut-module-setup.sh | 8 ++++++++
1 file changed, 8 insertions(+)
--- kexec-tools.orig/dracut-module-setup.sh
+++ kexec-tools/dracut-module-setup.sh
@@ -626,4 +626,12 @@ installkernel() {
[ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich
instmods $wdt
fi
+
+ if [ -c /dev/ttyUSB0 ]; then
+ _majmin=$(get_maj_min /dev/ttyUSB0)
+
+ _driver=$(readlink /sys/dev/char/$_majmin/device/driver)
+ _driver=$(basename $_driver)
+ instmods $_driver
+ fi
}
7 years
Question: is there any automated way of building rpm package?
by HATAYAMA Daisuke
Hello,
Is there any automated way of building rpm package?
That is, installing files such eppic, kexec-tools-po, makedumpfile and kexec-tools with expected file names necessary for installation, place them proper file path location and then execute rpmbuild command.
I first found out there's no Makefile and INSTALL file, and then I tried preparing them manually in an ad-hoc way, but faced build failure several times and gave up.
--
Thanks.
HATAYAMA, Daisuke
7 years, 11 months
[PATCH v3] dracut-module-setup: Fix the incorrect dumping target in atomic
by Minfei Huang
The kdump will dump the core in incorrect target directory
/sysroot/crash, if the target is bind mounted.
The /var is bind mounted in Atomic, kdump will dump the core in
/sysroot/crash, instead of /var/crash, if we specifies the value
"path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path, which
contains two part, one bind mounted path, the other specified dump
target.
Following is an example:
-bash-4.2# cat /etc/kdump.conf | grep ^path
path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]
-bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root
Then we can found it that the real path of dumping core is
/ostree/deploy/rhel-atomic-host/var/crash.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 29 +++++++++++++++++++----------
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++
mkdumprd | 4 +---
3 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ff7a088..b7ef56d 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -304,10 +304,19 @@ kdump_install_net() {
fi
}
+adjust_dump_target()
+{
+ local _fstype=$1 _target=$2 _path=$3
+ echo "$_fstype $_target" >> /tmp/$$-kdump.conf
+
+ #erase the old path line, then insert the parsed path
+ sed -i "/^path/d" /tmp/$$-kdump.conf
+ echo "path $_path" >> /tmp/$$-kdump.conf
+}
+
default_dump_target_install_conf()
{
local _target _fstype
- local _s _t
local _mntpoint
local _path _save_path
@@ -318,25 +327,25 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path)
- if [ "$_mntpoint" != "/" ]; then
- _fstype=$(get_fs_type_from_target $_target)
+ _fstype=$(get_fs_type_from_target $_target)
+ if is_bind_mount $_mntpoint; then
+ _path=${_save_path##"$_mntpoint"}
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ _path=$(get_bind_mount_directory $_mntpoint)/$_path
+
+ adjust_dump_target $_fstype $_target $_path
+ elif [ "$_mntpoint" != "/" ]; then
if $(is_fs_type_nfs $_fstype); then
kdump_install_net "$_target"
_fstype="nfs"
else
_target=$(kdump_to_udev_name $_target)
fi
-
- echo "$_fstype $_target" >> /tmp/$$-kdump.conf
-
_path=${_save_path##"$_mntpoint"}
- #erase the old path line, then insert the parsed path
- sed -i "/^path/d" /tmp/$$-kdump.conf
- echo "path $_path" >> /tmp/$$-kdump.conf
+ adjust_dump_target $_fstype $_target $_path
fi
-
}
#install kdump.conf and what user specifies in kdump.conf
diff --git a/kdump-lib.sh b/kdump-lib.sh
index f24f08d..d8a547a 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -86,6 +86,38 @@ get_root_fs_device()
return
}
+# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
+# in the SOURCE column for bind-mounts, then if $_mntpoint equals to
+# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
+is_bind_mount()
+{
+ local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
+ local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
+
+ if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+# the value of $_mntpoint will be
+# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
+# directory is bind mounted. The former part represents the device path, rest
+# part is the bind mounted directory which quotes by bracket "[]".
+get_bind_mount_directory()
+{
+ local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
+ local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
+
+ _mntpoint=${_mntpoint##$_mntpoint_nofsroot}
+
+ _mntpoint=${_mntpoint#[}
+ _mntpoint=${_mntpoint%]}
+
+ echo $_mntpoint
+}
+
get_mntpoint_from_path()
{
echo $(df $1 | tail -1 | awk '{print $NF}')
diff --git a/mkdumprd b/mkdumprd
index 4d251ba..951eb6d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -201,8 +201,7 @@ mkdir_save_path_ssh()
#Function: get_fs_size
#$1=dump target
get_fs_size() {
- local _mnt=$(to_mount_point $1)
- echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
+ echo -n $(df -P "$SAVE_PATH"|tail -1|awk '{print $4}')
}
#Function: get_raw_size
@@ -364,7 +363,6 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
_target=$(get_target_from_path $SAVE_PATH)
if [ "$_mntpoint" != "/" ]; then
- SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
_fstype=$(get_fs_type_from_target $_target)
if $(is_fs_type_nfs $_fstype); then
--
2.2.2
8 years, 3 months
[PATCH] make kdump saving directory name consistent with RHEL6
by WANG Chao
Now we use the pattern:
<machine/ipaddr>-YYYY.MM.DD-HH:MM:SS
while rhel6 uses the following:
<machine/ipaddr>-YYYY-MM-DD-HH:MM:SS
This change may break someone's script and we should change it back to
keep consistent between releases.
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
kdump-lib-initramfs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 57b8304..68a94e8 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -7,7 +7,7 @@ CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
DEFAULT_ACTION="reboot"
-DATEDIR=`date +%Y.%m.%d-%T`
+DATEDIR=`date +%Y-%m-%d-%T`
HOST_IP='127.0.0.1'
DUMP_INSTRUCTION=""
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
--
2.1.0
8 years, 3 months
[PATCH 0/2 v2] Crash dump is saved in /sysroot/crash instead of /var/crash in Atomic
by Minfei Huang
The kdump cannot dump the core in the correct directory in Atomic,
if set the path "/var/crash" in the /etc/kdump.conf. We found that
kdump cannot deal with the bind mounts correctly.
Fix this issue to make kdump dump core correctly.
v2:
- fix the issue to dump directory /var/crash correctly in Atomic.
- wrap the common function dump_common_fs to handle the dump core
- Add a new function to determine the directory is bind mounts or not
v1:
- fix the issue to dump directory /sysroot/var/crash instead of /sysroot/crash in Atomic
Minfei Huang (2):
dracut-moduel-setup: Filte the bind mounted directory in the Atomic
kdump-lib-initramfs: Dump the correct directory in the Atomic
kdump-lib-initramfs.sh | 91 +++++++++++++++++++++++++++++++++++++++++++-------
kdump-lib.sh | 43 +++++++++++++++++++++++-
2 files changed, 121 insertions(+), 13 deletions(-)
--
2.2.2
8 years, 3 months
[PATCH] dracut-module-setup.sh: change the insecure use of /tmp/*$$* filenames
by Baoquan He
Harald warned it's dangerous to use /tmp/*$$* in shell scripts of dracut
modules.
Quote his saying as below:
***************************
This can be exploited so easily and used to overwrite e.g. /etc/shadow.
The only thing you have to do is waiting until the next time the kdump
initramfs is generated on a kernel update.
If at all, please use "$initdir/tmp/" because $initdir is a mktemp generated
directory with a non-guessable name!
**************************
So make a clean up in this patch.
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
dracut-module-setup.sh | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ff7a088..4641025 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -3,6 +3,10 @@
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
+if ! [[ -d "${initdir}/tmp" ]]; then
+ mkdir -p "${initdir}/tmp"
+fi
+
check() {
[[ $debug ]] && set -x
#kdumpctl sets this explicitly
@@ -146,15 +150,15 @@ kdump_setup_team() {
echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf
#Buggy version teamdctl outputs to stderr!
#Try to use the latest version of teamd.
- teamdctl "$_netdev" config dump > /tmp/$$-$_netdev.conf
+ teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf
if [ $? -ne 0 ]
then
derror "teamdctl failed."
exit 1
fi
inst_dir /etc/teamd
- inst_simple /tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf"
- rm -f /tmp/$$-$_netdev.conf
+ inst_simple ${initdir}/tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf"
+ rm -f ${initdir}/tmp/$$-$_netdev.conf
}
kdump_setup_vlan() {
@@ -328,20 +332,20 @@ default_dump_target_install_conf()
_target=$(kdump_to_udev_name $_target)
fi
- echo "$_fstype $_target" >> /tmp/$$-kdump.conf
+ echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
#erase the old path line, then insert the parsed path
- sed -i "/^path/d" /tmp/$$-kdump.conf
- echo "path $_path" >> /tmp/$$-kdump.conf
+ sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
+ echo "path $_path" >> ${initdir}/tmp/$$-kdump.conf
fi
}
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
- sed -ne '/^#/!p' /etc/kdump.conf > /tmp/$$-kdump.conf
+ sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf
while read config_opt config_val;
do
@@ -349,7 +353,7 @@ kdump_install_conf() {
config_val=$(strip_comments $config_val)
case "$config_opt" in
ext[234]|xfs|btrfs|minix|raw)
- sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
+ sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf
;;
ssh|nfs)
kdump_install_net "$config_val"
@@ -365,9 +369,9 @@ kdump_install_conf() {
default_dump_target_install_conf
- kdump_configure_fence_kdump "/tmp/$$-kdump.conf"
- inst "/tmp/$$-kdump.conf" "/etc/kdump.conf"
- rm -f /tmp/$$-kdump.conf
+ kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
+ inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
+ rm -f ${initdir}/tmp/$$-kdump.conf
}
# Default sysctl parameters should suffice for kdump kernel.
--
1.9.3
8 years, 3 months
[PATCH 0/8 v8] Enhance kdump to support ipv6
by Minfei Huang
Enhance kdump to support ipv6 protocal.
Don't modify the code between v7 and v8. This version aids to cleanup
and re-construct the patchset.
v8:
- re-construct the patchset to make it more clear.
v7:
- use interface function is_ipv6_address to check whether is ipv6 or not
- fix some bugs
v6:
- construct the patches, split more small patches
- wrap the similar functional code to make it more clearly
v5:
- modify the get_route function
v4:
- consistent the netdevice name to add the prefix "kdump-" before the ethX
v3:
- Support the static route
v2:
- Fix some bugs
Minfei Huang (8):
kdump-lib: Quote the parameter to correct it if contains the blank
mkdumprd: Add proper prefix "kdump-" before ethX in 2nd kernel
kdump-lib: Add a new function to get the ip address
kdump-lib: Add functions to enhance ipv6 judgement
dracut-kdump: Use the first filtered ip address as the dumping
directory
dracut-module-setup: Support the static route with ipv6 mode
dracut-module-setup: Enhance kdump to support ipv6
dracut-module-setup: Enhance iscsi to support ipv6
dracut-kdump.sh | 4 +-
dracut-module-setup.sh | 162 ++++++++++++++++++++++++++++++++++++-------------
kdump-lib.sh | 52 +++++++++++++---
mkdumprd | 16 ++++-
4 files changed, 179 insertions(+), 55 deletions(-)
--
2.2.2
8 years, 3 months
[PATCH V2] module-setup.sh: install usb serial driver for ttyUSB0
by Dave Young
In case one want to use usb serial console, we need to pack the usb serial
driver into kdump initramfs so that one can see the console output on the usb
console.
I only handled ttyUSB0, this is like a hard code, but it should be enough for
most cases. Also only install the driver for the ttyUSB0 device.
Tested with adding "console=ttyUSB0" in 2nd kernel commandline.
Tested latest F22 kernel, there's CONFIG_USB_SERIAL_CONSOLE=y, kdump work ok.
Signed-off-by: Dave Young <dyoung(a)redhat.com>
---
[v1 -> v2]: use /sys/dev/char/$_majmin/device/driver/module for module name
It is better, for some driver the driver dir name is not same as the module name
such as keyspan usb adapter.
dracut-module-setup.sh | 8 ++++++++
1 file changed, 8 insertions(+)
--- kexec-tools.orig/dracut-module-setup.sh
+++ kexec-tools/dracut-module-setup.sh
@@ -626,4 +626,12 @@ installkernel() {
[ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich
instmods $wdt
fi
+
+ if [ -c /dev/ttyUSB0 ]; then
+ _majmin=$(get_maj_min /dev/ttyUSB0)
+
+ _driver=$(readlink /sys/dev/char/$_majmin/device/driver/module)
+ _driver=$(basename $_driver)
+ instmods $_driver
+ fi
}
8 years, 3 months
[Patch v2] execute kdump_post after do_default_action
by Baoquan He
User complains that kdump_post script doesn't execute after mount
failed. This happened since mount failure will trigger
kdump-error-handler.service, and then start kdump-error-handler.sh.
However in kdump-error-handler.sh it doesn't execute kdump_post.
Hence add it in this patch.
Surely the function do_kdump_post need be moved into kdump-lib-initramfs.sh
to be a common function.
v1->v2:
Add a return value to do_kdump_post when invoked in kdump_error-handler.sh.
And call do_kdump_post earlier than do_default_action, otherwise
it may not execute if reboot/poweroff/halt.
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
dracut-kdump-error-handler.sh | 1 +
dracut-kdump.sh | 7 -------
kdump-lib-initramfs.sh | 7 +++++++
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh
index 2f0f1d1..e0c6724 100755
--- a/dracut-kdump-error-handler.sh
+++ b/dracut-kdump-error-handler.sh
@@ -6,5 +6,6 @@ set -o pipefail
export PATH=$PATH:$KDUMP_SCRIPT_DIR
get_kdump_confs
+do_kdump_post 1
do_default_action
do_final_action
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index e062665..fa8908f 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -35,13 +35,6 @@ do_kdump_pre()
fi
}
-do_kdump_post()
-{
- if [ -n "$KDUMP_POST" ]; then
- "$KDUMP_POST" "$1"
- fi
-}
-
add_dump_code()
{
DUMP_INSTRUCTION=$1
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 57b8304..9f26f6c 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -161,3 +161,10 @@ do_final_action()
{
eval $FINAL_ACTION
}
+
+do_kdump_post()
+{
+ if [ -n "$KDUMP_POST" ]; then
+ "$KDUMP_POST" "$1"
+ fi
+}
--
1.8.5.3
8 years, 3 months
[PATCH v7 0/4] Enhance kdump to support ipv6
by Minfei Huang
v7:
- use interface function is_ipv6_address to check whether is ipv6 or not
- fix some bugs
v6:
- construct the patches, split more small patches
- wrap the similar functional code to make it more clearly
v5:
- modify the get_route function
v4:
- consistent the netdevice name to add the prefix "kdump-" before the ethX
v3:
- Support the static route
v2:
- Fix some bugs
Minfei Huang (4):
mkdumprd: Add proper prefix "kdump-" before ethX in 2nd kernel
kdump-lib: Add a new function to get the ip address
kdump-lib: Add new libs to enhance kdump to support ipv6
ipv6: Enhance kdump to support ipv6
dracut-kdump.sh | 4 +-
dracut-module-setup.sh | 163 ++++++++++++++++++++++++++++++++++++-------------
kdump-lib.sh | 47 +++++++++++---
mkdumprd | 16 ++++-
4 files changed, 175 insertions(+), 55 deletions(-)
--
1.9.3
8 years, 3 months