Author Topic: What I did today at work  (Read 284 times)

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
What I did today at work
« on: June 23, 2009, 07:38:28 PM »
VERIFY THAT THE ROOT DISKS TO REMAIN UNTOUCHED ARE IN H/W PATH 0/0/0 & 1/0/0

ioscan -funC disk


Add discs to be smashed:

Code: [Select]
for x in `ioscan -funC disk | awk {'A=$1;B=$3;C=$7;D=$8;getline;E=$1;F=$2;print B,F}' | grep -v 0/0/0 | grep -v 1/0/0 | awk '{print $2}'`
do pvcreate -f $x
done


Make a new Smash-It volume group:

mkdir /dev/vgsmashit && mknod /dev/vgsmashit/group c 64 0x040000

Quote
(if fails, increment by 10000, e.g. 0x050000; 0x060000)

rm -Rf /dev/vgsmashit && mknod /dev/vgsmashit/group c 64 0x050000
rm -Rf /dev/vgsmashit && mknod /dev/vgsmashit/group c 64 0x060000


Add discs to be smashed to the volume group you just created, and give them a physical volume group name:

Code: [Select]
for x in `ioscan -funC disk | awk {'A=$1;B=$3;C=$7;D=$8;getline;E=$1;F=$2;print B,E}' | grep -v 0/0/0 | grep -v 1/0/0 | awk '{print $2}' | grep dsk`
do vgcreate -g pvgsmashit vgsmashit $x


Make empty placeholder volumes, striped across your new pvg:

Code: [Select]
x=`vgdisplay -v vg00 | grep "LV Name" | grep lvol | awk '{print $3}'| wc -l`
while [ $(ls /dev/vgsmashit/lvol* | wc -l) -lt $x ]
do lvcreate -D y -s g /dev/vgsmashit
done


Inflate your volumes using 1024 blocks of  "Free PE" integer from vgdisplay vgsmashit output:

Code: [Select]
typeset -i I
I=1

x=1024
while [ $( vgdisplay vgsmashit | grep "Free PE" ) -gt 1024 ]; do
    lvextend -l $x /dev/vgsmashboot/lvol$I pvgsmashit
    I=$(( I + 1 ))
done


For every logical volume found in /dev/vgsmashit, create a filesystem on it and mount it:

Code: [Select]
for FILE in /dev/vgsmashit/lv*
do DIR=$( print $FILE | sed -e "s#/dev/vgsmashit/##" ) mkdir /tmp/$DIR mount -F vxfs $FILE /tmp/$DIR
done


Place the smash-it executable into the root filesystem, then run this command:

Code: [Select]
for x in `vgdisplay -v vgsmashboot | grep lvol | awk -F '/' '{print $4}'` ; do
FS=/tmp/$x
typeset -i I
I=0

while [ $( bdf $FS | grep -iv avail | grep -iv smashit | awk '{ print $3 }' | tr -d '%' ) -gt 0 ]; do
    dd if=/dev/zero of=$FS/smash$I bs=1024k seek=1024 count=1
    nohup /smash-it $FS/smash$I > /dev/null &
    I=$(( I + 1 ))
done





Unmount the smashed filesystems

umount /tmp/lvol*


Remove extents from the smashed logical volumes

Code: [Select]
for x in `cat /etc/lvmpvg | grep dsk`
do lvreduce -f -l 0 $x
done


Remove the smashed logical volumes

Code: [Select]
for x in `vgdisplay -v vgsmashit | grep lvol | awk '{print $3}'`
do lvremove -f $x
done


Remove the physical volumes from the smashed volume group

Code: [Select]
for x in `cat /etc/lvmpvg | grep dsk`
do vgreduce vgsmashit $x
done


Remove the smashed volume group

vgremove vgsmashit

...

So that's the entire thing all put together. 

I've not completed that last part yet.

Thanks for your help drax0r.