#!/bin/bash # # sysinfo-collect-quick # # Store some hardware information about the running system in the current # directory. # This is designed to be run from an openSUSE rescue system (which runs entirely # off RAMdisk once booted). # # Copyright (C) 2009-2013 by Volker Kuhlmann # http://volker.top.geek.nz/contact.html # All rights reserved. # Released under the terms of the GNU General Public License (GPL) Version 2. # See http://www.gnu.org/ for details. # # Volker Kuhlmann # 27 May 2009 # 20 May; 7 Jul 2010 # 3, 5 Feb; 15, 16 Apr 2011 # # Version 1.3 01 Jun 2011 # # Version 1.4 09 Apr 2012 # Store first 2048 blocks of disks. Save hwinfo. # # Version 1.5 22 Jan 2013 # Add output of a few more lsXXX, # and from 3 more programs of the dmidecode package. # # Version 1.6 05 Dec 2015 # Also output lsusb -v, acpi -V. # Only run old version of cfdisk - new one hangs in scripts! # Store first 4MB of hard disk as well; the first partition now starts at 4MB # by default. # Store all stderr output with stdout output. # Run all commands with set -x. # # Version 1.7 20 Jan 2016 # Also output lsparts. # # Version 1.8 30 Jan 2016 # Also output gdisk -l, sgdisk -p, parted -l. # # Disk to report on. Default /dev/sda, otherwise argument 1. diskdev="${1:-/dev/sda}" check_run_cmd() { if type -p "$1" >/dev/null; then ( set -x "$@" >"$1" 2>&1 ) else echo 2>&1 "No command $1!" fi } ( lspci echo "" echo "Detail:" set -x lspci -v -nn ) >lspci 2>&1 ( lsusb echo "" echo "Detail:" set -x lsusb -v ) >lsusb 2>&1 for prog in \ lsmod lsscsi \ lscpu lsdev lshal lsblk lsparts \ biosdecode ownership vpddecode dmidecode do check_run_cmd $prog done check_run_cmd acpi -V ( set -x cat /proc/cpuinfo >cpuinfo ) disk="${diskdev##*/}" # Device name after last slash. ( if fdisk -l -u=cylinders >/dev/null 2>&1; then set -x fdisk -l -u=sectors >fdisk-"$disk" 2>&1 "$diskdev" fdisk -l -u=cylinders >>fdisk-"$disk" 2>&1 "$diskdev" fdisk -l -u=sectors >fdisk-all 2>&1 fdisk -l -u=cylinders >>fdisk-all 2>&1 else set -x fdisk -lu >fdisk-"$disk" 2>&1 "$diskdev" fdisk -l >>fdisk-"$disk" 2>&1 "$diskdev" fdisk -lu >fdisk-all 2>&1 fdisk -l >>fdisk-all 2>&1 fi ) # Wow, cfdisk (from util-linux 2.25.1, openSUSE 13.2) is completely different # now - it can't list the partition table any longer, and hangs in scripts, # reading from terminal even with stdin from /dev/null. # The useless version shows version with -V and exits 0, # the useful one shows error and exits 1 with -V. if ! cfdisk -V >/dev/null 2>&1; then ( set -x # cfdisk only lists the first disk, or the disk specified. cfdisk -Ps >cfdisk-"$disk" 2>&1 "$diskdev" cfdisk -Pt >>cfdisk-"$disk" 2>&1 "$diskdev" #cfdisk -Pr >>cfdisk-"$disk" 2>&1 "$diskdev" ) fi ( set -x sfdisk -d >sfdisk-"$disk" 2>&1 "$diskdev" sfdisk -l -uB >>sfdisk-"$disk" 2>&1 "$diskdev" sfdisk -l -uS >>sfdisk-"$disk" 2>&1 "$diskdev" sfdisk -l -uC >>sfdisk-"$disk" 2>&1 "$diskdev" sfdisk -l -uM >>sfdisk-"$disk" 2>&1 "$diskdev" dd count=63 if="$diskdev" of=first63blocks-"$disk".diskimg dd count=2048 if="$diskdev" of=first1M-"$disk".diskimg dd count=8192 if="$diskdev" of=first4M-"$disk".diskimg ) # Only gdisk -l , sgdisk -p , parted -l can list GPT tables with real # sector numbers instead of human-readable units. check_run_cmd gdisk -l "$disk" check_run_cmd sgdisk -p "$disk" check_run_cmd parted -l "$disk" # Run last, it hangs sometimes. check_run_cmd hwinfo