]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add sosreport script and generate /run/initramfs/sosreport.txt
authorHarald Hoyer <harald@redhat.com>
Wed, 21 Nov 2012 13:07:54 +0000 (14:07 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 21 Nov 2012 13:17:43 +0000 (14:17 +0100)
dracut.8.asc
dracut.asc
dracut.cmdline.7.asc
modules.d/98systemd/dracut-emergency.service
modules.d/99base/dracut-lib.sh
modules.d/99base/module-setup.sh
modules.d/99base/sosreport.sh [new file with mode: 0755]

index 5062db3ff4d78aefd5b79e1abb6ce2722085dff4..6300055159adfe90cf668b3b07e567f4ec02eedc 100644 (file)
@@ -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
 -------
 
index d24ebe6c3e3fe0a7b3212d1a8218254c07540ca6..094673880f77e61b822493b1be927215a6520e5c 100644 (file)
@@ -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.
index 2a746045415a1dfddba6a9a12742aad124a1c187..4ab77a6bccf3bcbbe2acfbb48a38cdb1773cf84f 100644 (file)
@@ -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
index 4ec7861278cad9ce809cf7bccdb191b75c5dac3f..d08bfe7c314b2eedd476404462b47bdbb3082a2b 100644 (file)
@@ -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
index 313f4146f507c8730722c264ff2f36eab66eb7ef..cc6c7e81205593cb41a3c8f58c4623e104be07a0 100755 (executable)
@@ -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
index fb4763cfc083110476bf5fa7b8a2d15dc40b3bcc..a512868b21685fd41cdbeb730d1ba6bbd2e6bcc4 100755 (executable)
@@ -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 (executable)
index 0000000..2aded6b
--- /dev/null
@@ -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
+