Bind Mounts and File System Mount Order

Source: Internet
Author: User

When you have bind mount the option of the command, you must is sure that the file systems is mounted in the correct Orde R. In the following example, the /var/log directory must is mounted before executing the bind mount on the /tmp directory:

Mount --bind/var/log/tmp

The ordering of file system mounts is determined as follows:

    1. In general, file system mount order was determined by the order in which the file systems appear in the fstab file . The exceptions to this ordering is file systems mounted with the _netdev flag or file systems, that has their own< c5> init Scripts.

    2. A file system with its own init script was mounted later in the initialization process, after the file systems in the file.
      The main idea is that after the initialization process, a filesystem with its own init script will be mounted, however, after the file system listed in the Fstab file is mounted. In other words, the mount order is slower than fstab

    3. File systems mounted with the _netdev flag is mounted when the network have been enabled on the system.

If your configuration requires that you create a bind mount on which to mount a GFS2 the file system, you can order your file as follows:

    1. Mount local file systems that is required for the bind mount.

    2. Bind mount the directory on which to mount the GFS2 file system.

    3. Mount the GFS2 file system.

If your configuration requires that you bind mount a local directory or file system onto a GFS2 file system, listing the F Ile systems in the correct order in the fstab file would not mount the file systems correctly since the GFS2 file system WI ll not being mounted until the GFS2 init script is run. In this case, you should write a script to execute the bind mount so, the bind mount would not take a place init until After the GFS2 file system is mounted.

The following script is a example of a custom init script. This script performs a bind mount of directories onto a GFS2 file system. In this example, there is a existing GFS2 mount point /mnt/gfs2a at, which was mounted when the GFS2 init script runs, after C Luster startup.

In this example script, the values of the chkconfig statement indicate the following:

    • 345 indicates the run levels that the script would be a started in

    • Are the start priority, which in the indicates, the script would run at startup time after the GFS2 init scrip T, which have a start priority of 26

    • Indicates that the script would be stopped during shutdown before the GFS2 Scri which PT, which have a stop priority of 74

The start and stop values indicate so you can manually perform the indicated action by executing a and service start a service stop com Mand. For example, if the script is named fredwilma and then you can execute service fredwilma start .

This script should is put in the directory with the same permissions as the other scripts in that /etc/init.d directory. You can then execute a chkconfig on command-to-link the script to the indicated run levels. For example, if the script is named fredwilma and then you can execute chkconfig fredwilma on .

#!/bin/bash## chkconfig:345  in  the# Description:Mount/unmount My custom bind mounts onto a GFS2 subdirectory##### BEGIN init info# provides: # # # END init INFO./etc/init.d/functions Case " $" inchstart) # In this example, Fred and Wilma want their home directories # bind-mounted over the GFS2 directory/mnt/gfs2a,whichHas # been mounted as/mnt/gfs2amkdir-p/mnt/gfs2a/home/fred &>/dev/NULL    mkdir-p/mnt/gfs2a/home/wilma &>/dev/NULL/bin/Mount--bind/mnt/gfs2a/home/fred/home/Fred/bin/Mount--bind/mnt/gfs2a/home/wilma/home/Wilma;; Stop)/bin/Umount/mnt/gfs2a/home/Fred/bin/Umount/mnt/gfs2a/home/Wilma;;  status);; Restart) $0Stop $0start;; Reload) $0start;; *)        Echo$"Usage: $ {start|stop|restart|reload|status}"Exit1EsacExit0

Bind Mounts and File System Mount Order

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.