47

I'm just wondering if I need to restart my server after editing fstab and mtab. I changed something in this file manually due to problem with awstats report.

I am using ISPConfig 3 with the help of the tutorial from howtoforge. But due to removing/deleting of some account, the configuration of fstab and mtab messed up.

I also ask this question at howtoforge forum but until now no one has answered. If you'd like to read my question please visit it here.

I tried very hard to fix the problem w/o luck.

Update:

Here's what happen to my fstab:

Before the value was (I omitted the other):

/var/log/ispconfig/httpd/mydomain.com /var/www/clients/client1/web1/log    none    bind,nobootwait    0 0
/var/log/ispconfig/httpd/example.com /var/www/clients/client1/web2/log    none    bind,nobootwait    0 0

So I changed it to the correct path:

/var/log/ispconfig/httpd/mydomain.com /var/www/clients/client1/web2/log    none    bind,nobootwait    0 0
/var/log/ispconfig/httpd/example.com /var/www/clients/client1/web3/log    none    bind,nobootwait    0 0

I also found mtab to have the same value as above that's why I edited it manually.

from:

/var/log/ispconfig/httpd/mydomain.com /var/www/clients/client1/web1/log none rw,bind 0 0
/var/log/ispconfig/httpd/example.com /var/www/clients/client1/web2/log none rw,bind 0 0

to:

/var/log/ispconfig/httpd/mydomain.com /var/www/clients/client1/web2/log none rw,bind 0 0
/var/log/ispconfig/httpd/example.com /var/www/clients/client1/web3/log none rw,bind 0 0

I edited those value because the correct path of mydomain.com and example.com should be under web2 and web3 folder respectively.

As of now the log of example.com is pointed to:

/var/www/clients/client1/web2/log

when it should be:

/var/www/clients/client1/web3/log

So I am thinking that this is because of fstab and mtab.

Please guide me how to point the log correctly to it's default directory.

I explain the scenario one by one at this link.

msrd0
  • 240
  • 3
  • 13
jaypabs
  • 773
  • 2
  • 9
  • 15

3 Answers3

55

File /etc/mtab is maintained by the operating system. Don't edit it.

File /etc/fstab defines what should be mounted. It is read at system start.

When I add an extra disk to a system that should be mounted at system start I add it to /etc/fstab.

To check the correctness of the updated /etc/fstab I use the command mount -a. That reads /etc/fstab as system start, it mounts filesytems that aren'nt yet mounted.

It gives an error when the mountpoint is missing or the device is missing.

To answer the question on rebooting: No, there is no need to reboot after editing /etc/fstab. You can testdrive with mount -a

Geert Stappers
  • 551
  • 3
  • 2
  • 17
    Usually the problem is that `mount -a` won't remount filesystems that're already mounted. Instead one would rather use `mount -o remount`, like `sudo mount / -o remount`. It will use the options defined in the fstab. – Hi-Angel Feb 18 '16 at 14:01
  • @Geert Stappers, I modified /etc/fstab on Ubuntu Linux 16.04 today and it almost crashed my system. In other words, It keeps asking for emergency reboot. Thank you – Frank May 24 '16 at 15:24
  • This didn't work for me on 16.04 guest in VMWare Fusion. I had to extend my primary partition which meant I had to remove the existing swap partition to make room. I edited fstab with the new partition info, but `mount -a` did not make the system recognize the new swap partition. Rebooting did work though. – Steven Lu Nov 04 '16 at 18:21
  • FYI: manpage of `mount` states that it is a bad practice to use `mount -a` for checking `/etc/fstab` after editing. To quote: `Note that it is a bad practice to use mount -a for fstab checking. The recommended solution is findmnt --verify.`. – haxpor Sep 12 '20 at 18:53
11

You don't edit /etc/mtab manually.

You can, though, change your /etc/fstab to add or remove persistent mount points, i.e. the ones that will be mounted on startup. Also, the /etc/fstab file is used by the mount(8) command to refer to mount points.

You can safely define new mount points, or delete existing ones in /etc/fstab without altering the current state of the OS. You can manually mount(8) and umount(8) filesystems that reflect those changes; and you can also remount already mounted filesystems with dfferent options, e.g.:

mount -o remount,noexec /var

The question here is, why do you think you need bind mount points at all and what do you think you are going to achieve by using them? But I disgress.

When dealing with bind mount points, the steps to reconfigure your filesystems layout without restarting should be:

  1. Don't edit /etc/mtab manually
  2. stop the applications and services that use the filesystems you are going to modify. This is not always possible, but your use case seems to involve only filesystems dedicated to host log files under /var.
  3. umount all bind mount points.
  4. rewrite /etc/fstab to match your needs.
  5. manually mount the filesystems.
dawud
  • 14,918
  • 3
  • 41
  • 61
  • Hi, I update my post above. Please read the scenario. – jaypabs Jun 27 '13 at 10:15
  • Actually I don't know why there is a bind mount points. I'm using the tutorial from [link](http://bit.ly/JVth4Y) and I did not add it myself... – jaypabs Jun 27 '13 at 12:01
  • One way to avoid stopping and starting individual services (which could be a chore), is to pass in single user mode (`telinit S`), do the edits, and move back to multiuser(`telinit 2`). – didierc Feb 14 '15 at 18:45
0

mtab lists currently mounted filesystems, so it is written by the system and its content will change after, say, a reboot, an umount or a new mount. fstab lists available filesystems and is persistent, i.e. it will survive a reboot.

You should not edit mtab directly.

blau
  • 728
  • 3
  • 9