[SunHELP] Listing Disk Sizes...
Sheldon T. Hall
shel at cmhcsys.com
Sun Feb 2 18:25:36 CST 2003
"Wyatt Draggoo" <wyatt at draggoo.com> writes
> I need to get a list of the disks attached to an Ultra 5, along with the
> total size of the disk, in a script under Solaris 7. Most of the commands
> that deal with sizes (df, du) are per-partition, and format, which lists
> the disks, is interactive, which doesn't help a lot in a script.
>
> I'm sure there is a command to get this list, but a search through this
> list archive and both google and groups.google hasn't turned up anything
> for me.
It's not a part of Solaris, but the "scsiinfo" program will tell you what
disks are attached, or, with different options, what their sizes are.
The output is really designed for humans, rather than scripts, but you could
grep/awk/sed through the output fairly easily to produce the reports you
need.
That's assuming you have SCSI disks on your Ultra 5s ... if they have IDE
disks, I don't suppose scsiinfo would be too useful, but maybe there's an
"ideinfo" or other IDE equivalent.
If all else fails, you could use the output from "dk -k", appropriately
sorted, and use awk to get the totals.
This script doesn't do what you want, but it does show you how to get the
totals:
#!/bin/sh
#
# last_dump - combine the output of df with /etc/dumpdates to show usable
# information about filesystem names, sizes, and dump dates.
#
# Created 1/10/03 STH
#
# Set up and clear temp files
tmp1=/tmp/last_dump.tmp1.$$
tmp2=/tmp/last_dump.tmp2.$$
> $tmp1
> $tmp2
# Get the output for the local ufs filesystems, without "/dev/dsk/" prefix
df -F ufs -k | grep "/" | cut -c10-80 | sort > $tmp1
# For each filesystem, find its "c0d0t0s0" matching line in /etc/dumpdates
for fs in `cut -d' ' -f1 $tmp1`
do
grep $fs /etc/dumpdates | cut -c11-80 >> $tmp2
done
# Show the results
echo " Dump Current"
echo "------------------------------------- -----------------------"
echo "Device Lvl Date %used Used Free
Filesystem"
echo
"-------- --- ------------------------ ----- -------- -------- ------------
-----"
paste $tmp2 $tmp1 | \
awk '{printf "%s %s %s %s %2s %s %s %4s %8s %8s %s\n",\
$1, $2, $3, $4, $5, $6, $7, $12, $10, $11, $NF}
{sum += $10}
END {printf "Total in use
%8s\n",sum}'
rm -f $tmp1
rm -f $tmp2
exit 0
# END
-Shel
More information about the SunHELP
mailing list