We have plenty of linux server that will mount a few linux file server by NFS or SMB using /etc/fstab

But manually changing each server's /etc/fstab is very tedious.

Is there any way to edit multiple linux server's /etc/fstab simultaneously?

  • What is your window for 'simultaneous' ?
    – user9517
    Jul 2, 2014 at 8:53
  • 5
    Yes that's called centralized configuration management and/or orchestration.
    – HBruijn
    Jul 2, 2014 at 9:00
  • i think webmin can do this, using cluster tab from gui Jan 26, 2017 at 14:33

4 Answers 4


Long term, this is the sort of tasks that configuration management tools (e.g., puppet, chef, ansible) are made for.

For a short term solution, I'd use something like func or fabric to push out your fstab file. Going to run through an example of using fabric since that's the one I'm most familiar with.

Installation depends on your distro. One of these is likely to work:

$ sudo pip install fabric
$ sudo easy_install fabric
$ sudo apt-get install fabric

Then, you'll also need to distribute ssh keys. It's simple:

$ ssh-keygen
$ ssh-copy-id host2
$ ssh-copy-id host3

Now, you'll need to create a fab file (pretty much a Python script). For example, copy_fstab.fab would look something like this:

from fabric.operations import put
from fabric.operations import sudo

def copy_fstab():
    # Copy local fstab over
    put('/etc/fstab', '/etc/fstab', use_sudo=True)

    # Run mount -a
    sudo('mount -a')

Finally, you run the fab file:

$ fab -H host2,host3 copy_fstab

Hope this helps!

  • 1
    This replaces your whole file. I wouldn't do that. Why would I want custom stuff like that, one file per server, in a mass deployment tool? Is that what this does? I strongly prefer a thing like fstab.d (which doesn't exist) to allow having just one small addition.
    – Peter
    Jul 3, 2014 at 10:42
  • Agree with Peter; this is going to be painful with local disks even using device nodes rather than UUIDs.
    – symcbean
    Jul 3, 2014 at 10:49
  • I would rather deploy something like Puppet frankly. But if it's a one time sync, creating a fab with some sed commands and such would get the job done. Jul 3, 2014 at 11:24

Using a mass deployment tool like automateit, salt, puppet, ansible, etc. you could run a script (in puppet use exec) or a cronjob like below to use mount to run a mass deployed fstab:

mount -a --fstab pathtofile

And my old answer (if your mount is too old to have --fstab / -T): in such a mass deployment tool, you could do some terrible hackery to emulate an /etc/fstab.d behavior (since /etc/fstab.d is not yet supported, and those directories make deployment tools very useful).

Move fstab to /etc/fstab.d/01main

Deploy your fstab line in a file /etc/fstab.d/02nfsstuff

Merge them (here the number order is important):

cat /etc/fstab.d/* > /etc/fstab

Make a horrible hackjob cronjob in /etc/cron.d/nfsstuff

0 * * * * root cat /etc/fstab.d/* > /etc/fstab ; mount -a

I hope you find a proper solution, but until then, maybe this is useful.


I agree with Peter that using a deployment tool is the neatest solution. However I disagree that mouning stuff from cron is ever a good idea!

If the deployment tool is too much of a leap, I'd go with a late init/systemd script (which might fetch the definitions from a central respository) and mount the filesystems.

  • I didn't say it was a good idea ;) I just said it was a hackish idea. And I provided it despite that because there is no fstab.d or equivalent, so I'm sure there will be no perfect answer.
    – Peter
    Jul 3, 2014 at 10:45

Assuming I have an admin account on each server available via SSH with public-key auth, I would simply remotely run sed or other text editing tool using this SSH account, in a bash loop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .