grub-install cannot find /boot device

Got this fine hint from the gentoo grub error collection
Could Not Find Device For /boot/boot: Not Found Or Not a Block Device
Situation
When running grub-install during the GRUB installation, you receive the
following error:
Grub Output
# grub-install –root-directory=/boot /dev/hda
Could not find device for /boot/boot: not found or not a block device
Solution
Check that you didn’t forget the following:
Updating the mtab file
# cp /proc/mounts /etc/mtab
213/433

Metafree

If you want to know how much space you have free for soft partitioning use Adrian Ball's script "metafree", get it at:
http://majords.co.uk/scripts/metafree
or just copy/paste this:
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
168/433
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
=="-p" {print }' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
*### It's a metadevice, use metastat to find the size
*cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
169/433
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
*### It's a real device, work out size assuming full disk/LUN is used
*cap=$(prtvtoc $c | nawk '
kraftek.html POSTS rescue rescued.html rescued.txt x y z /bytes/sector/ {bs=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
170/433
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /sectors/cyl/ {sc=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
171/433
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /accessible cyl/ {as=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
172/433
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z END kraftek.html POSTS rescue rescued.html rescued.txt x y z {print bs*sc*as/1024^3}')
else
*### Assume we have a cXtX form of device, use prtvtoc to work out
*### the size of the slice
*cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
kraftek.html POSTS rescue rescued.html rescued.txt x y z BEGIN {split(c,a,"s"); s=a[2]}
kraftek.html POSTS rescue rescued.html rescued.txt x y z /bytes/sector/ {bs=
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
173/433
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
}
kraftek.html POSTS rescue rescued.html rescued.txt x y z ==s {print *bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
kraftek.html POSTS rescue rescued.html rescued.txt x y z
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
174/433
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
=="-p" && ==c {split(
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft
Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
175/433
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct %
"$devs"
done
,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }*
END** { print used/2048/1024 }
')
echo $cap $used | nawk '{print -
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
176/433
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done
,
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
177/433
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done
/*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '==c &&
#!/bin/ksh
#
# metafree - Adrian Ball (ade@majords.co. uk)- 2007/01
#
# Finds all devices containing soft partitions and shows
# size/allocation, unallocated space, devices etc
#
# NB: This is
not
the script that is listed on Sun's BigAdmin site
# I had written this before knowing of that one's existence, but
# subsequently found all the links to that one to be broken, so
# I have not seen it.
# Strangely I had picked the same name for the script...
# Maybe someone will find this one useful.
if [[ ! -x /usr/sbin/metastat ]] ; then
echo "Can't run metastat binary, bogus..."
exit 1
fi
printf "%-20s %9s %9s %10s %10s %sn" Device GB Used Available Capacity "Soft Partitions"
for c in $(metastat -p | nawk '$2=="-p" {print $3}' | sort -u) ; do
if [[ ${c%%[0-9]*} == d ]] ; then
### It's a metadevice, use metastat to find the size
cap=$(metastat $c 2>/dev/null| nawk '/Size:/ {print $2/2048/1024;exit}')
elif [[ ${c#/} != $c ]] ; then
### It's a real device, work out size assuming full disk/LUN is used
cap=$(prtvtoc $c | nawk '
/bytes/sector/ {bs=$2}
/sectors/cyl/ {sc=$2}
/accessible cyl/ {as=$2}
END {print bs*sc*as/1024^3}')
else
### Assume we have a cXtX form of device, use prtvtoc to work out
### the size of the slice
cap=$(prtvtoc /dev/rdsk/$c | nawk -v c=$c '
BEGIN {split(c,a,"s"); s=a[2]}
/bytes/sector/ {bs=$2}
$1==s {print $5*bs/1024^3}')
fi
used=$(metastat -p | nawk -v c=$c '
$2=="-p" && $3==c {split($0,a,"-o")
for (frag in a) { split(a[frag], sz,"-b"); used+=sz[2] } }
END { print used/2048/1024 }
')
echo $cap $used | nawk '{print $1-$2, $2/$1*100}' | read avail pct
devs=$(metastat -p | sort | nawk -v c=$c '$3==c && $2="-p" {printf "%s ", $1}')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
178/433
done
="-p" {printf "%s ", }')
printf "%-20s %9.2f %9.2f %10.2f %9.1f%1s %sn" $c $cap $used $avail $pct % "$devs"
done

Automate ssh login with expect

Sometimes you are not allowed to use keys to autologin to your machines, so you must find a way to automate your
login using password authentication.
This expect script can help you do it:
#!/usr/local/bin/expect —
set timeout 30
spawn ssh user@ipaddress
while 1 {
expect {
“*(yes/no)?” { send “yesn”}
“*password:” { send “passwordn”}
“*user]#” { send “shutdown -h nownexitn”}
}
}
266/433

rstatd performance daemon

Well, i didn’t know that rstatd can be used to obtain a remote’s server performance counters….
It is usually disabled for security purposes.
Just make sure it is configured at /etc/inetd.conf, by uncommenting the proper line
bash-2.05# grep rstat /etc/services
bash-2.05# grep rstat /etc/inetd.conf
rstatd/2-4 tli rpc/datagram_v wait root /usr/lib/netsvc/rstat/rpc.rstatd rpc.rstatd
Then restart inetd
bash-2.05# ps -ef | grep inetd
root 355 1 0 Apr 26 x y z 0:00 /usr/sbin/inetd -s -t
bash-2.05# kill -HUP 355
It will be running
bash-2.05# ps -ef | grep rstat
root 23620 23616 0 18:01:48 pts/1 0:00 grep rstat
root 21694 355 0 17:39:37 x y z 0:01 rpc.rstatd
You can use a fine rstatd client called java perfmeter: http://jperfmeter.sourceforge.net/
If you have CDE you can use sdtperfmeter
bash-3.00$ /usr/dt/bin/sdtperfmeter othermachine
If you have gnome, you might as well use gnome-perfmeter
# gnome-perfmeter othermachine
242/433

Translate / Convert ssd to cxtxdx

You can translate ssd disk syntax to cxtxdx (c$t$d$) by comparing iostat -E to iostat -En output:
iostat -E | grep Soft | awk ‘{ print $1}’ > /tmp/a; iostat -En | grep Soft|awk ‘{ print $1 }’ > /tmp/b; paste /tmp/a
/tmp/b
sd6 c0t6d0
ssd0 c1t1d0
ssd1 c1t0d0
ssd2 c1t3d0
ssd3 c1t4d0
ssd4 c1t5d0
ssd5 c4t3d0
ssd6 c4t4d0
ssd7 c1t2d0
ssd8 c4t5d0
ssd9 c4t2d0
ssd10 c4t1d0
ssd11 c4t0d0
Thanks to Hiram Ruiz
230/433

My Apache virtual hosts

I have some domains on a single machine, over a single dynamic DNS connection, that means a single ip, and I need to
show a different page for each domain name it is accessed.
This is the section of my httpd.conf that enables that:
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs/ttoes
ServerName www.ttoes.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs
ServerName www.kraftek.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/apache2/htdocs
ServerName rdircio.no-ip.org
</VirtualHost>

how to know if you have java with 64 bit libraries

if you get this message then you don’t have 64 bit java
bash-3.00# java -d64 -version
execve(): No such file or directory
Error trying to exec /usr/jdk/instances/jdk1.5.0/bin/sparcv9/java.
Check if file exists and permissions are set correctly.
Failed to start a 64-bit JVM process from a 32-bit JVM.
Verify all necessary J2SE components have been installed.
(Solaris SPARC 64-bit components must be installed after 32-bit components.)
if you get this message then you have 64 bit java 🙂
bash-3.00# java -d64 -version
java version “1.6.0_18”
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
8/433

Enable sar system accounting on solaris8 and 9

To enable sysstat’s sar to collect stats in the background:
# ln -s /etc/init.d/perf /etc/rc2.d/S21perf
# /etc/rc2.d/S21perf start
Use “crontab -e sys” to make sure sys crontab looks like:
0 kraftek.html POSTS rescue rescued.html rescued.txt x y z kraftek.html POSTS rescue rescued.html rescued.txt x y z kraftek.html POSTS rescue rescued.html rescued.txt x y z 0-6 /usr/lib/sa/sa1
20,40 8-17 kraftek.html POSTS rescue rescued.html rescued.txt x y z kraftek.html POSTS rescue rescued.html rescued.txt x y z 1-5 /usr/lib/sa/sa1
5 18 kraftek.html POSTS rescue rescued.html rescued.txt x y z kraftek.html POSTS rescue rescued.html rescued.txt x y z 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A
To verify, issue “sar -A” or just “sar”