12

Can I include another file in my fstab file?

I.e. can I have fstab execute lines from another file at an arbitrary point, and then return to the main file when completed?

10

Generally not, but with newer versions of mount/swapon/fsck... on Linux (from util-linux 2.19) at least, you can have more files (with .fstab extension) in /etc/fstab.d. So you can have a /etc/fstab.d/00_header.fstab, /etc/fstab.d/50_middle.fstab, /etc/fstab.d/99_end.fstab.

Another approach if all you want is mount -a to run some command is have an entry with your own filesystem type and create a /sbin/mount.own that does the work for you.

Note that recent versions of Ubuntu have that mountall that might get in the way.

Also note that some distributions process mounts in several stages using -t fstypes, which you may need to take into account as well.

0

I have never seen a Unixy system with such an fstab(5)-setup. Look at mount(8) for the gory details of what can be done at mount time.

What do yu want this for? If really useful in more than a narrow range of usecases it just might get implemented...

  • 3
    I have a lot of computers that mount the same nfs, I want to centralize the fstab life relating to that nfs (so I don't have to change it on all machines when it changes) – jsj Jan 28 '13 at 11:01
  • Do you have an svn or another version control system? Or if you have config management like salt, chef, puppet, ..etc? In the case of svn, you can have a script that checks out from svn, and then builds/appends to /etc/fstab, monitor it periodically, compare from svn. If you have a config management, you can build your fstab from a template. For example, in salt, you can use jinja2 template to build the mounts portion of your /etc/fstab, and that would also prevent accidental typing errors. – R J Jan 21 '18 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.