System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script for unmounting all filesystem and deactivating VGs over ssh

 
Anshif
Occasional Contributor

Script for unmounting all filesystem and deactivating VGs over ssh

Hi,
Do anyone have a script alreay using on HPUX for ssh into a group of servers and unmounting all filesystems and deactivating the VGs?
I want to unmount all filesystems and deactivtae VGS excpet VG00.
Can anyone help me on this. I am not good at scripting so all your help will be a great help

Thanks
5 REPLIES
Dennis Handly
Acclaimed Contributor

Re: Script for unmounting all filesystem and deactivating VGs over ssh

Any particular problem you are trying to solve?
You can't unmount ALL filesystems without rebooting.
Johnson Punniyalingam
Honored Contributor

Re: Script for unmounting all filesystem and deactivating VGs over ssh

seems to be you have duplicate thread.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1409419
Problems are common to all, but attitude makes the difference
Anshif
Occasional Contributor

Re: Script for unmounting all filesystem and deactivating VGs over ssh

Whenever we need to perform any SAN activities where we have to unmount all filesystems and deactivate VGS, i am wondering if i have a script which can just trigger from one box and then it will ssh into each server and unmount all filesystems which mounted from SAN. and then deactivate particular VGs.
James R. Ferguson
Acclaimed Contributor

Re: Script for unmounting all filesystem and deactivating VGs over ssh

Hi:

> Whenever we need to perform any SAN activities where we have to unmount all filesystems and deactivate VGS,

You could write something yourself. Read the lines of a list of filesystem names and volume groups. Knowing the filesystem names you would probably have to kill any processes using them ('fuser -k'); then unmount the filesystem; and finally use 'vgchange -a n' to deactivate the volume group.

The "guts" of your script might look something like:

#!/usr/bin/sh
MYFILESYS=/var/tmp/myfilesys
MYVGS=/var/tmp/myvgs
cat <<- EOF
filesys1
filesys2
filesys3
filesysX
filesysY
EOF > ${MYFILESYS}

cat <<- EOF
vg01
vg02
vg03
EOF > ${MYVGS}

while read FS
do
kill -k ${FS}
umount ${FS}
done < ${MYFILESYS}
while read VG
do
vgchange -a n ${VG}
done < ${MYVGS}
exit 0

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Script for unmounting all filesystem and deactivating VGs over ssh

Hi:

Here's a more viable script that drives its actions from the '/etc/fstab' of each server:

# cat ./sanmaint
#!/usr/bin/sh
MYVGS=/var/tmp/myvgs
while read DEV MNTPT X
do
VG=$( echo ${DEV} | awk '/^\/dev\// {split($1,a,"/");print a[3]}' )
if [ ! -z "${VG}" -a "${VG}" != "vg00" ]; then
echo fuser -k ${MNTPT} #...remove 'echo' to activate
echo ${VG} > ${MYVGS}
fi
done < /etc/fstab
sort -u ${MYVGS} | while read VG
do
echo vgchange -a n ${VG} #...remove 'echo' to activate
done
rm ${MYVGS}
exit 0

Regards!

...JRF...