1837020 Members
2185 Online
110111 Solutions
New Discussion

Re: fstab

 
System Dude_1
Frequent Advisor

fstab

Dear Friend,

I would like to do a script to comment out some mount point in the fstab as below :

/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /opt vxfs delaylog 0 2
/dev/vg00/lvol6 /tmp vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
/dev/vg06/lvol9 /app vxfs rw,suid,delaylog,datainlog 0 2
/dev/vg06/lvol1 /oradata vxfs rw,suid,delaylog,datainlog 0 2
/dev/vg06/lvol1 /oradata1 vxfs rw,suid,delaylog,datainlog 0 2

to be as below :

/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /opt vxfs delaylog 0 2
/dev/vg00/lvol6 /tmp vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
#/dev/vg06/lvol9 /app vxfs rw,suid,delaylog,datainlog 0 2
#/dev/vg06/lvol1 /oradata vxfs rw,suid,delaylog,datainlog 0 2
#/dev/vg06/lvol1 /oradata1 vxfs rw,suid,delaylog,datainlog 0 2

and the script could create additional mount point as below :

/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /opt vxfs delaylog 0 2
/dev/vg00/lvol6 /tmp vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
#/dev/vg06/lvol9 /app vxfs rw,suid,delaylog,datainlog 0 2
#/dev/vg06/lvol1 /oradata vxfs rw,suid,delaylog,datainlog 0 2
#/dev/vg06/lvol1 /oradata1 vxfs rw,suid,delaylog,datainlog 0 2

/dev/vg07/lvol9 /app1 vxfs rw,suid,delaylog,datainlog 0 2
/dev/vg07/lvol1 /oradata2 vxfs rw,suid,delaylog,datainlog 0 2
/dev/vg07/lvol1 /oradata3 vxfs rw,suid,delaylog,datainlog 0 2

Thks



Performance Issue on HP-UX 10.20
8 REPLIES 8
Clemens van Everdingen
Honored Contributor

Re: fstab

Hi,

Why script it, just do it by hand with vi.

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
System Dude_1
Frequent Advisor

Re: fstab

I'm doing a migration and a lot of thing take care off. So i want it to be automate.
Performance Issue on HP-UX 10.20
Clemens van Everdingen
Honored Contributor

Re: fstab

Hi,

Sorry I am not a script kiddie, so no further suggestions.

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
John Carr_2
Honored Contributor

Re: fstab

Hi

comments are not officially supported in the fstab file.

if you have to this its easiest to have several versions of the file and copy them in as appropiate.

John.
John Carr_2
Honored Contributor

Re: fstab

Hi

I have just had another look at the fstab file and this is really not a good idea. It would be more sensible to have all the entries in one file then automate mounting and unmounting the file systems using cron or at or a script.

good luck
John.
Trond Haugen
Honored Contributor

Re: fstab

As comments are not supported a simple vi with a here document could change the lines.

vi /etc/fstab << EOF
:g/vg06/s//vg07/
:wq!
EOF

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Shannon Petry
Honored Contributor

Re: fstab

What you are doing doesnt make much sense. While you could automate modifying the fstab file by itself it would not check for mounts, nor would it umount the difference between files.

I agree with the others that you are better to make 2 copies of the fstab file. It is silly to write a script to make the same 3 changes to fstab every time it's run.

Here are a few pointers for scripting.

Use ksh or sh, because what you are doing is not really complex.

To check for directories in a script (see "man test").

if [ -d /somedir ] ; then
echo "I have /somedir"
else
mkdir /somedir
fi

To see if something is mounted..

TESTDIR=`/etc/mount|grep somedir|awk '{print $1}'`

if [ -n $TESTDIR ] ; then
echo "/somedir is mounted"
#stick umount here...
else
echo "/somedir is not mounted"
#stick mount here.
fi

I would recommend that you get a book published by O'Reilly and Associates called "Unix System Administration". It will give you scripting pointers, as well as what NOT to do (like put comments in fstab). This book covers HP-UX, Solaris, Irix, Aix, and Linux as well as a bit of SCO. It is not very complex on any specific system, but gives good practical advice for the basics on each major brand of UNIX.

Regards,
Shannon
Microsoft. When do you want a virus today?
Holger Knoppik
Valued Contributor

Re: fstab

Hi,

for commenting out special vgs, try this:

#!/bin/sh
#
#
# set -x
echo "Enter pattern: \c"
read mod_pattern
ed /etc/fstab <1,\$s/${mod_pattern}/#${mod_pattern}
w
q
EOF

HTH,
RGDS, Holger
Live long and prosper!