16

After adding a new mount point in /etc/fstab, we usually execute mount -a to reflect the change (if we want to bypass reboot), and df -kh output shows the new mount point.

How does mount -a work/impact already mounted partitions, which have reference to the /etc/fstab file?  Does it umount and then mount those partitions, or just ignore them since they are already mounted?

1
  • 2
    Why do you usually run mount -a instead of just mount <thenewmountpoint>? Commented Jun 15, 2019 at 4:11

3 Answers 3

24

It skips ones already mounted.

https://github.com/karelzak/util-linux/blob/master/sys-utils/mount.c#L185-L193

while (mnt_context_next_mount(cxt, itr, &fs, &mntrc, &ignored) == 0) {

    const char *tgt = mnt_fs_get_target(fs);

    if (ignored) {
        if (mnt_context_is_verbose(cxt))
            printf(ignored == 1 ? _("%-25s: ignored\n") :
                          _("%-25s: already mounted\n"),
                   tgt);
    }
    // ...
}
5

It will ignore already mounted partitions.

In the same time, you can do a mount -o remount /dev/xxx on a partition already mounted, this won't cause any problem even if users are using this partition

0

The better option would be mount the new file system manually and add the new file system entry in the /etc/fstab to make sure this f/s get mounted on every reboot.

As mentioned above "mount -a" will ignore the already mounted file systems and mount only the file system which was not mounted yet (new file system).

Hope this will helps.

1
  • 2
    I prefer "mount -a" option for a new file system rather than manually mount it. In this way, I'm also verifying if /etc/fstab entry is correct. Commented Jun 23, 2019 at 13:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.