how to bulk update /etc/fstab file

I have about 50 linux servers need updating the records inside /etc/fstab file.

The only change is from  those that have netapp:/vol/vol_orabackup mounted to svm2nfs:/vol_orabackup.

The original is netapp:/vol_orabackup      /orabackup       nfs     rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,noac,vers=3,timeo=600

The destination is svm2nfs:/vol_orabackup      /orabackup       nfs     rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,noac,vers=3,timeo=600

 Can I write a script and run the script to update it?

I heard about some configuration update tool, is there a tool I can use to manage all configuration files on linux. thank you.
Jason YuAsked:
Who is Participating?
 
Duncan RoeSoftware DeveloperCommented:
The original Q asked how to change netapp:/vol_orabackup to svm2nfs:/vol_orabackup (i.e. with no /vol component to remove) so I stick by my suggested sed line in http:#a40731046
Were there a /vol to remove, I would suggest s+netapp:/vol+svm2nfs+ i.e. use a delimiter that does not occur in the original or replacement string
0
 
Jason YuAuthor Commented:
I got the following lines as below, please give your advise:

#!/bin/bash

DIRECTORY=/orabackup2

if [ ! -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
  mkdir /orabackup2
fi


#Create temporary file with new line in place

cat /etc/fstab | sed -e "s/netapp\:\/vol/svm2nfs/" > /tmp/test1

#Copy the new file over the original file

mv /tmp/test1 /etc/fstab

Open in new window

0
 
Duncan RoeSoftware DeveloperCommented:
The sed command looks wrong to me. I find it best to use a delimiter other than slash when editing text containing slashes. Although in this case you don't really need any slashes: how about 's/netapp/svm2nfs/'
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
gheistCommented:
You should not use long netapp mount options meant for DB data mounts for 1) backup volume 2) non-netapp volumes
0
 
Duncan RoeSoftware DeveloperCommented:
@gheist: In this context, netapp is simply a host name is it not?
0
 
Jason YuAuthor Commented:
Yes, netapp is just a share name on netapp storage device.
0
 
gheistCommented:
I am absolutely sure that netapp changed their recommendation to r/wsize=64k couple of years ago.
0
 
gheistCommented:
sed (
sed -i s/netapp:\/vol/svm2nfs/g /etc/fstab
0
 
gheistCommented:
Yes, but add -i parameter to edit in-place...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.