Disk Information Fedora | Linux

2009-06-01T17:25:53Z
Dave Pawson.  link
Home

Disk Information Fedora | Linux

Last week or so I've had an annoying (tiny) rattle from my PC. Eventually I took notice of it, took it apart and traced it to one of two fans in the PSU. 80mm, I had a spare so I stripped out the PSU and took it apart. Drat. It's about 15mm deep, common case fans are nearer 15mm deep. No, I tried, it wouldn't fit. Google found one from Zalman, the ZM-0P1 80mm Slim Fan, but they seem to be a rare beast. Clearly they don't shift the air volume. Anyway, I put it all back together again... only to hit trouble.

On booting, grub reported

Bad magic number on superblock while trying to open /dev/sda6

Oh shh . Rechecked all my connections (which I must admit are a bit messy in the case). Seemed OK. Booted into level 1 and checked out /etc/fstab. Then I became suspicious. How can I play with a disk setup, seems its OK to have a disk not listed in fstab yet connected, but if it's in fstab, it appears it must be connected? Surely that can't be right. Anyway, I started from scratch and reconnected all my drives, one at a time, starting with my boot disk (sdb, which I'd forgotten, that fooled me) and adding one at a time - there are only three. On connecting the last one, up she came and booted into Fedora. Phew.

I decided I needed more disk information, so off I want and came up with the following script to obtain an easy, up to date list of what's connected. I guess it needs printing and keeping, since it's not much good on the screen... when I can't boot. This is good for my setup, YMMV. I'm Fedora, SATA drives.

#!/bin/bash
# Obtain all useful disk information. 
# Single parameter is the required output file. 

if [ $# -ne 1 ]
  then
    echo Usage: diskinfo.sh outputfile
    exit 2
fi


op=$1
if [ -f ${op}  ]
    then
    mv -f ${op} ${op}.Original
    echo "${op} backed up to ${op}.Original"
fi

echo " " > ${op}
if [ ! -w $1  ]
    then
    echo $1 must be writable.
    exit 2
fi




#
#Import general functions
#
#Not required


nl(){
echo  >>${op}
 >>${op}
}



echo -n "Created "  >${op}
date -u '+%Y-%m-%dT%H:%M:%S'  >>${op}
nl

# OS
echo -n "OS version info"
echo `uname -a`  >>${op}
nl

#Devices, sizes
echo "Device sizes" >>${op}
fdisk -l | grep "Disk /d" >>${op}
nl


# map device to mount point
echo "Device to mount point"  >>${op}
df -hT | grep ^/dev >>${op}

#map device partitions
nl
echo "Device partitions, type">>${op}
fdisk -l | grep ^/dev >>${op}
nl

#fstab 
cat /etc/fstab  >>${op}
nl

# uuids
echo uuid for each disk >>${op}
ls -l /dev/disk/by-uuid | gawk   '{print $10,  $8}' >>${op}
nl


#
#Print results
#
more ${op}



Others may find it useful. Especially if printed!

Keywords: hardware

Comments (View)

Return to main index