From 64d144aece158c8a26d104d6c7e1196e014c6b88 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 21 Nov 2012 14:07:54 +0100 Subject: Add sosreport script and generate /run/initramfs/sosreport.txt --- dracut.8.asc | 7 ++++ dracut.asc | 1 + dracut.cmdline.7.asc | 13 ++++++-- modules.d/98systemd/dracut-emergency.service | 3 +- modules.d/99base/dracut-lib.sh | 17 ++++++++-- modules.d/99base/module-setup.sh | 1 + modules.d/99base/sosreport.sh | 49 ++++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 6 deletions(-) create mode 100755 modules.d/99base/sosreport.sh diff --git a/dracut.8.asc b/dracut.8.asc index 5062db3f..63000551 100644 --- a/dracut.8.asc +++ b/dracut.8.asc @@ -30,6 +30,13 @@ early userspace. For a complete list of kernel command line options see *dracut.cmdline*(7). +If you are dropped to an emergency shell, while booting your initramfs, +the file _/run/initramfs/sosreport.txt_ is created, which can be safed to a +(to be mounted by hand) partition (usually /boot) or a USB stick. +Additional debugging info can be produced by adding **rd.debug** to the kernel command line. +_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools. +It should be attached to any report about dracut problems. + EXAMPLE ------- diff --git a/dracut.asc b/dracut.asc index d24ebe6c..09467388 100644 --- a/dracut.asc +++ b/dracut.asc @@ -466,6 +466,7 @@ dracut shell commands are printed as they are executed ---- # journalctl -ab ---- +. With dracut >= 025 the file /run/initramfs/sosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later. If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that. Then you can store the output for later inspection. diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc index 2a746045..4ab77a6b 100644 --- a/dracut.cmdline.7.asc +++ b/dracut.cmdline.7.asc @@ -124,6 +124,12 @@ Misc [[dracutkerneldebug]] Debug ~~~~~ +If you are dropped to an emergency shell, the file _/run/initramfs/sosreport.txt_ is created, +which can be safed to a (to be mounted by hand) partition (usually /boot) or a USB stick. +Additional debugging info can be produced by adding **rd.debug** to the kernel command line. +_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools. +It should be attached to any report about dracut problems. + **rd.info**:: print informational output though "quiet" is set @@ -131,8 +137,11 @@ Debug allow dropping to a shell, if root mounting fails **rd.debug**:: - set -x for the dracut shell and logs to dmesg, console and - _/run/initramfs/init.log_ + set -x for the dracut shell. + If systemd is active in the initramfs, all output is logged to the systemd journal, + which you can inspect with "journalctl -ab". + If systemd is not active, the logs are written to dmesg and _/run/initramfs/init.log_. + If "quiet" is set, it also logs to the console. **rd.break**:: drop to a shell at the end diff --git a/modules.d/98systemd/dracut-emergency.service b/modules.d/98systemd/dracut-emergency.service index 4ec78612..d08bfe7c 100644 --- a/modules.d/98systemd/dracut-emergency.service +++ b/modules.d/98systemd/dracut-emergency.service @@ -15,7 +15,8 @@ DefaultDependencies=no Environment=HOME=/ WorkingDirectory=/ ExecStartPre=-/bin/plymouth quit -ExecStartPre=-/bin/echo -e '\n\nEntering emergency mode. Exit the shell to continue.\nType "journalctl" to view system logs.\n' +ExecStartPre=-/sbin/sosreport +ExecStartPre=-/bin/echo -e '\n\nEntering emergency mode. Exit the shell to continue.\nType "journalctl" to view system logs.\nYou might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot\nafter mounting them and attach it to a bug report.\n\n' ExecStart=-/bin/sh -i -l ExecStopPost=-/bin/rm -f /.console_lock Type=oneshot diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 313f4146..cc6c7e81 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -879,12 +879,23 @@ _emergency_shell() systemctl start dracut-emergency.service rm -f /.console_lock else - echo "Dropping to debug shell." + debug_off + echo + /sbin/sosreport + echo 'You might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot' + echo 'after mounting them and attach it to a bug report.' + if ! RD_DEBUG= getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then + echo + echo 'To get more debug information in the report,' + echo 'reboot with "rd.debug" added to the kernel command line.' + fi + echo + echo 'Dropping to debug shell.' echo export PS1="$_name:\${PWD}# " [ -e /.profile ] || >/.profile - _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" + _ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" if [ -z "$_ctty" ]; then _ctty=console while [ -f /sys/class/tty/$_ctty/active ]; do @@ -920,7 +931,7 @@ emergency_shell() if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then _emergency_shell $_rdshell_name else - warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line." + warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line." # cause a kernel panic exit 1 fi diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index fb4763cf..a512868b 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -32,6 +32,7 @@ install() { inst_script "$moddir/init.sh" "/init" inst_script "$moddir/initqueue.sh" "/sbin/initqueue" inst_script "$moddir/loginit.sh" "/sbin/loginit" + inst_script "$moddir/sosreport.sh" "/sbin/sosreport" [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib mkdir -m 0755 -p ${initdir}/lib/dracut diff --git a/modules.d/99base/sosreport.sh b/modules.d/99base/sosreport.sh new file mode 100755 index 00000000..2aded6b0 --- /dev/null +++ b/modules.d/99base/sosreport.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +echo 'Generating "/run/initramfs/sosreport.txt"' + +exec >/run/initramfs/sosreport.txt 2>&1 + +set -x + +cat /proc/self/mountinfo +cat /proc/mounts + +blkid +blkid -o udev + +ls -l /dev/disk/by* + +cat /proc/cmdline + +[ -f /etc/cmdline ] && cat /etc/cmdline + +for _i in /etc/cmdline.d/*.conf; do + [ -f "$_i" ] || break + echo $_i + cat $_i +done + +for _i in /etc/conf.d/*.conf; do + [ -f "$_i" ] || break + echo $_i + cat $_i +done + +if command -v lvm >/dev/null 2>/dev/null; then + lvm pvdisplay + lvm vgdisplay + lvm lvdisplay +fi + +command -v dmsetup >/dev/null 2>/dev/null && dmsetup ls --tree + +cat /proc/mdstat + +if command -v journalctl >/dev/null 2>/dev/null; then + journalctl -ab --no-pager +else + dmesg + [ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log +fi + -- cgit v1.2.3