0

Iam very new to linux. suppose i have two file with same name fstab one file is located in /etc and the other is located in /root/ If i make a change in /etc/fstab file the changes has to reflect in /root/fstab . Is there any command to do this? Kindly help me...

Mythili

Sean Reifschneider
  • 10,720
  • 3
  • 25
  • 28

3 Answers3

3

Given your comment to @ewwhite, a symbolic link won't solve your problem. The symbolic link will be replicated, but not the file contents. You have several options. The simple one:

  • Periodically copy /etc/fstab to /root/fstab using a cron job.

More work but exactly what you want:

  • Use something like incron to arrange for a script to run whenever /etc/fstab changes. This can then copy the file to wherever the file needs to go.
larsks
  • 43,623
  • 14
  • 121
  • 180
  • But based on the comment to @ewwhite, cron is probably also not a good option. There are procedures and tools specifically for doing this in a DRBD environment, including /etc/fstab and other files/directories. See my response for more details. – Sean Reifschneider Nov 23 '10 at 13:43
1

You could use a symbolic link to the original file in /etc/fstab.

ln -s /etc/fstab /root/fstab

That creates a link at /root/fstab that points to the file at /etc/fstab.

May I ask why you need to see that file in multiple locations? Why not just use /etc/fstab?

ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • Iam using HA drbd for replication.My replicated device is in one partion(sda3) and /etc is in one partion.After failover only the file in sda3 are replicating.In my case files are replicating but the fstab file of (/etc/) also has to change at a time. –  Nov 23 '10 at 12:37
  • Yes, the DRBD scenario changes this a bit... I'd go with one of the purpose-built utilities or some thing like a scheduled synchronization. – ewwhite Nov 23 '10 at 15:32
0

For /etc/fstab on Linux-HA, you typically would not change /etc/fstab as part of the resource start. Normally what you would do is list all the mount-points you may have, but ones that are not always mounted list with "noauto". For example:

/dev/drbd0           /shared              ext3       defaults,noauto,noatime 0 0
/dev/drbd1           /var/lib/pgsql       ext3 defaults,noauto,noatime 0 0

At boot time those file-systems will not be mounted. Then, to bring those file-systems up you would list a resource like:

Filesystem::/dev/drbd0::/shared::ext3 \
Filesystem::/dev/drbd1::/var/lib/pgsql/::ext3 \

Additionally, you may wish to look at drbdlinks (probably available in your distro) which manages links to DRBD file-systems. However, I don't think you want to make /etc/fstab a drbdlink...

Sean Reifschneider
  • 10,720
  • 3
  • 25
  • 28