[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, 6 months
[PATCH v2] dracut-module-setup: Apply the manual DNS to the 2nd kernel
by Minfei Huang
Now Kdump will ingore the DNS config in /etc/resolv.conf, when it
generates the initram. And most users do not concern about this issue,
because they never use deployment tools to configure machines
environment, like puppet.
It is more convenient to add the DNS config to /etc/resolv.conf for
people who use deployment tools to configure machines concurrently.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
v1:
- check the file existence firstly, then print the file content
---
dracut-module-setup.sh | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 228fae2..957e53e 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -64,10 +64,25 @@ kdump_is_vlan() {
# $1: netdev name
kdump_setup_dns() {
- _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
+ local _nameserver _dns
+ local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
. /etc/sysconfig/network-scripts/ifcfg-$1
+
[ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+
+ while read content;
+ do
+ _nameserver=$(echo $content | grep ^nameserver)
+ [ -z "$_nameserver" ] && continue
+
+ _dns=$(echo $_nameserver | cut -d' ' -f2)
+ [ -z "$_dns" ] && continue
+
+ if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
+ echo "nameserver=$_dns" >> "$_dnsfile"
+ fi
+ done < "/etc/resolv.conf"
}
#$1: netdev name
--
2.1.0
8 years, 5 months
[PATCH] dracut-module-setup: Apply the manual DNS to the 2nd kernel
by Minfei Huang
Now Kdump will ingore the DNS config in /etc/resolv.conf, when it
generates the initram. And most users do not concern about this issue,
because they never use deployment tools to configure machines
environment, like puppet.
It is more convenient to add the DNS config to /etc/resolv.conf for
people who use deployment tools to configure machines concurrently.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 73ab938..ad842b2 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -64,10 +64,26 @@ kdump_is_vlan() {
# $1: netdev name
kdump_setup_dns() {
- _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
+ local _nameserver _dns
+ local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
. /etc/sysconfig/network-scripts/ifcfg-$1
+
+ touch $_dnsfile
[ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+
+ while read content;
+ do
+ _nameserver=$(echo $content | grep ^nameserver)
+ [ -z "$_nameserver" ] && continue
+
+ _dns=$(echo $_nameserver | cut -d' ' -f2)
+ [ -z "$_dns" ] && continue
+
+ if ! $(cat $_dnsfile | grep -q $_dns); then
+ echo "nameserver=$_dns" >> "$_dnsfile"
+ fi
+ done < "/etc/resolv.conf"
}
#$1: netdev name
--
2.1.0
8 years, 5 months
[PATCH] Revert: dracut-kdump: Use proper the known hosts entry in the file known_hosts
by Minfei Huang
commit 63476302aa09b7844ac0fff5aa3878bcc9a5bc0d
Since the patch is related to ipv6 feature, now we have not merge the
ipv6 patchset yet. So revert it, and will apply this patch, once the
ipv6 patchset is already.
There are a lot of patches to be merged after this patch, we revert it
manually.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-kdump.sh | 23 -----------------------
dracut-module-setup.sh | 16 ++++++++++++++++
kdump-lib.sh | 51 --------------------------------------------------
3 files changed, 16 insertions(+), 74 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index e062665..dc948d1 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -131,27 +131,6 @@ get_host_ip()
return 0
}
-# kdump will change the ethernet device name in the 2nd using prefix "kdump-",
-# the link scope of ipv6 has the format like fe80::5054:ff:fe48:ca80%eth0,
-# So we should correct the known hosts
-correct_known_hosts()
-{
- if is_ipv6_target && is_ssh_dump_target; then
- local _ipv6 _netdev _pre_netdev
- local _known_hosts="/root/.ssh/known_hosts"
- local _srcaddr=$(get_option_value ssh)
-
- [ "x" = "x""$_srcaddr" ] && return 1
-
- if `echo $_srcaddr | grep -q "%"`; then
- _ipv6=`get_remote_host $_srcaddr`
- _netdev=${_srcaddr#*-}
- _pre_netdev=$(kdump_setup_ifname $_netdev)
- sed -i "s#$_ipv6\%$_netdev#$_ipv6\%$_pre_netdev#" $_known_hosts
- fi
- fi
-}
-
read_kdump_conf()
{
if [ ! -f "$KDUMP_CONF" ]; then
@@ -196,8 +175,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
-correct_known_hosts
-
if [ -z "$DUMP_INSTRUCTION" ]; then
add_dump_code "dump_fs $NEWROOT"
fi
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 73ab938..228fae2 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -101,6 +101,22 @@ kdump_get_perm_addr() {
fi
}
+# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0
+# Because kernel assigned names are not persistent between 1st and 2nd
+# kernel. We could probably end up with eth0 being eth1, eth0 being
+# eth1, and naming conflict happens.
+kdump_setup_ifname() {
+ local _ifname
+
+ if [[ $1 =~ eth* ]]; then
+ _ifname="kdump-$1"
+ else
+ _ifname="$1"
+ fi
+
+ echo "$_ifname"
+}
+
kdump_setup_bridge() {
local _netdev=$1
local _brif _dev _mac _kdumpdev
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 2abb513..e62b4e2 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -197,57 +197,6 @@ check_save_path_fs()
fi
}
-
-# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0
-# Because kernel assigned names are not persistent between 1st and 2nd
-# kernel. We could probably end up with eth0 being eth1, eth0 being
-# eth1, and naming conflict happens.
-kdump_setup_ifname() {
- local _ifname
-
- if [[ $1 =~ eth* ]]; then
- _ifname="kdump-$1"
- else
- _ifname="$1"
- fi
-
- echo "$_ifname"
-}
-
-# get ip address or hostname from nfs/ssh config value
-get_remote_host()
-{
- local _config_val=$1
-
- # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
- # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- _config_val=${_config_val%\%*}
- echo $_config_val
-}
-
-# check the remote server ip address tpye
-is_ipv6_target()
-{
- local _server _server_tmp
-
- if is_ssh_dump_target; then
- _server=`get_option_value ssh`
- elif is_nfs_dump_target; then
- _server=`get_option_value nfs`
- fi
-
- [ -z "$_server" ] && return 1
- _server=`get_remote_host $_server`
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server | grep -q ":"
-}
-
is_atomic()
{
grep -q "ostree" /proc/cmdline
--
2.1.0
8 years, 5 months
[PATCH v10 0/8] Enhance kdump to support ipv6 protocal.
by Minfei Huang
Enhance kdump to support ipv6 protocal.
v10:
- re-intergate the patch structure and fix some small issue base on dyoung's comment
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 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: Support the static ip with ipv6 mode
dracut-module-setup: Parse the ipv6 to get the parameter to install
network in 2nd kernel
dracut-module-setup: Enhance iscsi to support ipv6
dracut-kdump.sh | 4 +-
dracut-module-setup.sh | 162 ++++++++++++++++++++++++++++++++++++-------------
kdump-lib.sh | 60 ++++++++++++++----
mkdumprd | 16 ++++-
4 files changed, 186 insertions(+), 56 deletions(-)
--
2.1.0
8 years, 5 months
[PATCH RHEL7.2 v3] kdumpctl: Add the command "kdumpctl showmem" to show the reserved memory
by Minfei Huang
Resolves: bz1140774
https://bugzilla.redhat.com/show_bug.cgi?id=1140774
If the grub kernel commandline is set to crashkernel=auto, it will not
expand the crashkernel=auto in the /proc/cmdline. It still says
crashkernel=auto.
Using /sys to determines crashkernel actual size is confusing since
there is no unit of measure.
Add a new command "kdumpctl showmem" to show the reserved memory kindly.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
Acked-by: Baoquan He <bhe(a)redhat.com>
---
kdumpctl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 5b2b3a3..029ded9 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -556,6 +556,14 @@ propagate_ssh_key()
fi
}
+show_reserved_mem()
+{
+ local mem=$(cat /sys/kernel/kexec_crash_size)
+ local mem_mb=$(expr $mem / 1024 / 1024)
+
+ echo "Reserved "$mem_mb"MB memory for crash kernel"
+}
+
is_fadump_capable()
{
# Check if firmware-assisted dump is enabled
@@ -967,8 +975,11 @@ main ()
propagate)
propagate_ssh_key
;;
+ showmem)
+ show_reserved_mem
+ ;;
*)
- echo $"Usage: $0 {start|stop|status|restart|propagate}"
+ echo $"Usage: $0 {start|stop|status|restart|propagate|showmem}"
exit 1
esac
}
--
2.1.0
8 years, 5 months
[PATCH V3] mkdumprd: Fix the bug to get persistent device correctly
by Minfei Huang
As you know, each filesystem instance is unique, and we can use UUID
which is generated by mkfs to identify the specified filesystem. Fstabe
can use the UUID to mount the specified filesystem on the directory
which is specified in the /etc/fstab.
udev will create following soft-link, once we mount the device(s) on
directory successfully.
$ ls -l /dev/disk/by-uuid/
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 21b7296c-13b3-4c9f-8b80-07a76ca26a49 -> ../../vda1
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 6a808f08-1391-4fe5-90e3-107371a72742 -> ../../vda2
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 dc97ae60-2abf-4804-8122-6cae176274e3 -> ../../vda3
In gereral, we can use device name to find the filesystem UUID in
/dev/disk. But it fails, if a filesystem is integrated by seveal
devices, like btrfs. Following is the structure of btrfs.
$ btrfs filesystem show /mnt/btrfs
Label: none uuid: b7ee07cd-6b28-43ec-aaed-af269bbcc0c9
Total devices 3 FS bytes used 240.00KiB
devid 1 size 1.00GiB used 232.25MiB path /dev/mapper/testvg-lvtest01
devid 2 size 1.00GiB used 92.88MiB path /dev/mapper/testvg-lvtest02
devid 3 size 500.00MiB used 220.25MiB path /dev/mapper/testvg-lvtest03
When we list the content of /dev/disk/by-uuid, we can find
/dev/dm-0[1] points to the corresponding UUID.
$ ls -al /dev/disk/by-uuid/
total 0
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 21b7296c-13b3-4c9f-8b80-07a76ca26a49 -> ../../vda1
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 6a808f08-1391-4fe5-90e3-107371a72742 -> ../../vda2
lrwxrwxrwx. 1 root root 10 Jun 15 15:45 dc97ae60-2abf-4804-8122-6cae176274e3 -> ../../vda3
lrwxrwxrwx. 1 root root 10 Jun 15 15:48 b7ee07cd-6b28-43ec-aaed-af269bbcc0c9 -> ../../dm-0
Thus Kdump maybe fail to the find UUID, once user specifies the
device in kdump.conf.
In order to fix this issue, we can use blkid to point out the UUID.
Here is some content from blkid manpage.
- Note that blkid reads information directly from devices and for
non-root users it returns cached unverified information.
- Avoid using the symlinks directly; it is not reliable to use the
symlinks without verification.
[1] The structure of lvm volume.
[root@localhost ~]# ls -al /dev/testvg/
total 0
lrwxrwxrwx. 1 root root 7 Jun 15 15:48 lvtest01 -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jun 15 15:48 lvtest02 -> ../dm-1
lrwxrwxrwx. 1 root root 7 Jun 15 15:48 lvtest03 -> ../dm-2
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
mkdumprd | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 28ecdd7..4e69526 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -30,14 +30,14 @@ perror() {
}
get_persistent_dev() {
- local i _tmp _dev
+ local i _tmp _dev _uuid
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
[ -z "$_dev" ] && {
perror_exit "Kernel dev name of $1 is not found."
}
- for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do
+ for i in /dev/mapper/* /dev/disk/by-id/*; do
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then
echo $i
@@ -45,6 +45,18 @@ get_persistent_dev() {
fi
done
+ if [ "x" != "x""$(blkid $1 | grep "UUID")" ]; then
+ _uuid=`blkid $1 | grep "UUID" | awk '{print $2}'`
+ _uuid=${_uuid#*\"}
+ _uuid=${_uuid%\"*}
+ _dev=/dev/disk/by-uuid/$_uuid
+ _tmp=$(udevadm info --query=name --name=$_dev 2>/dev/null)
+ if [ "x" != "x"$_tmp ]; then
+ echo $_dev
+ return
+ fi
+ fi
+
perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name"
echo $1
}
--
2.1.0
8 years, 5 months
[PATCH v2] kdumpctl: Add the command "kdumpctl showmem" to show the reserved memory
by Minfei Huang
If the grub kernel commandline is set to crashkernel=auto, it will not
expand the crashkernel=auto in the /proc/cmdline. It still says
crashkernel=auto.
Using /sys to determines crashkernel actual size is confusing since
there is no unit of measure.
Add a new command "kdumpctl showmem" to show the reserved memory kindly.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
Acked-by: Baoquan He <bhe(a)redhat.com>
---
v1:
- modify the function structure
---
kdumpctl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index ca053a1..4f47ba0 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -551,6 +551,14 @@ propagate_ssh_key()
fi
}
+show_reserved_mem()
+{
+ local mem=$(cat /sys/kernel/kexec_crash_size)
+ local mem_mb=$(expr $mem / 1024 / 1024)
+
+ echo "Crash kernel reserved "$mem_mb"MB memory"
+}
+
is_fadump_capable()
{
# Check if firmware-assisted dump is enabled
@@ -924,8 +932,11 @@ main ()
propagate)
propagate_ssh_key
;;
+ showmem)
+ show_reserved_mem
+ ;;
*)
- echo $"Usage: $0 {start|stop|status|restart|propagate}"
+ echo $"Usage: $0 {start|stop|status|restart|propagate|showmem}"
exit 1
esac
}
--
2.1.0
8 years, 5 months
[PATCH] kdumpctl: Add the command "kdumpctl showmem" to show the reserved memory
by Minfei Huang
If the grub kernel commandline is set to crashkernel=auto, it will not
expand the crashkernel=auto in the /proc/cmdline. It still says
crashkernel=auto.
Using /sys to determines crashkernel actual size is confusing since
there is no unit of measure.
Add a new command "kdumpctl showmem" to show the reserved memory kindly.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
---
kdumpctl | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index ca053a1..4f3c60d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -551,6 +551,17 @@ propagate_ssh_key()
fi
}
+show_reserved_mem()
+{
+ local mem_reserved=$(cat /sys/kernel/kexec_crash_size)
+ if [ $mem_reserved -eq 0 ]
+ then
+ echo "No memory reserved for crash kernel."
+ return
+ fi
+ echo "The kdump service reserved memory is `expr $mem_reserved / 1024 / 1024`MB"
+}
+
is_fadump_capable()
{
# Check if firmware-assisted dump is enabled
@@ -924,8 +935,11 @@ main ()
propagate)
propagate_ssh_key
;;
+ showmem)
+ show_reserved_mem
+ ;;
*)
- echo $"Usage: $0 {start|stop|status|restart|propagate}"
+ echo $"Usage: $0 {start|stop|status|restart|propagate|showmem}"
exit 1
esac
}
--
1.9.3
8 years, 5 months
[PATCH v3] Enhance kdump.conf "default" parameters check.
by Qiao Zhao
According to man page, default option can only use reboot, halt, poweroff,
shell and dump_to_rootfs as parameter.
Currently, if configuration kdump.conf is:
------
path /var/crash
core_collector makedumpfile -nosuchfile
default no_such_option
------
kdump service still can be started.
Adding function "check_default_config" to kdumpctl file can solve
this problem.
I have tested this patch in my test machine(Fedora-21).
v1 --> v2
Baoquan He point "check_default_config" function should be call in
"check_config" function.
Wang Li point if kdump.conf donesn't configure the "default" option,
kdump serivce will fail.
Signed-off-by: Qiao Zhao <qzhao(a)redhat.com>
---
kdumpctl | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index ca053a1..eaf7f67 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -259,6 +259,8 @@ check_config()
esac
done < $KDUMP_CONFIG_FILE
+ check_default_config || return 1
+
check_fence_kdump_config || return 1
return 0
@@ -781,6 +783,25 @@ start_dump()
return $?
}
+check_default_config()
+{
+ local default_option
+
+ default_option=$(awk '$1 ~ /^default$/ {print $2;}' $KDUMP_CONFIG_FILE)
+ if [ -z "$default_option" ]; then
+ return 0
+ else
+ case "$default_option" in
+ reboot|halt|poweroff|shell|dump_to_rootfs)
+ return 0
+ ;;
+ *)
+ echo $"Usage kdump.conf: default {reboot|halt|poweroff|shell|dump_to_rootfs}"
+ return 1
+ esac
+ fi
+}
+
start()
{
check_config
--
1.9.3
8 years, 5 months