7

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
    Why do you usually run mount -a instead of just mount <thenewmountpoint>? – RonJohn Jun 15 at 4:11
14

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.

  • 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. – Rauf Jun 23 at 13:56

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.