When you use the bind option of the mount command, you must be sure that the file systems are mounted in the correct order. In the following example, the /var/log directory must be 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 is determined by the order in which the file systems appear in the fstab file. The exceptions to this ordering are file systems mounted with the _netdev flag or file systems that have their own init scripts.

  2. A file system with its own init script is mounted later in the initialization process, after the file systems in the fstab file.

    大意是:在初始化过程中,一个带有自身init脚本的文件系统会被挂载,不过,这要在fstab这个文件中所列出的文件系统被挂载之后。也就是说,挂载次序慢于fstab中的文件系统

  3. File systems mounted with the _netdev flag are mounted when the network has been enabled on the system.

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

  1. Mount local file systems that are 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 file systems in the correct order in the fstab file will not mount the file systems correctly since the GFS2 file system will not be mounted until the GFS2 init script is run. In this case, you should write an init script to execute the bind mount so that the bind mount will not take place until after the GFS2 file system is mounted.

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

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

  • 345 indicates the run levels that the script will be started in

  • 29 is the start priority, which in this case indicates that the script will run at startup time after the GFS2 init script, which has a start priority of 26

  • 73 is the stop priority, which in this case indicates that the script will be stopped during shutdown before the GFS2 script, which has a stop priority of 74

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

This script should be put in the /etc/init.d directory with the same permissions as the other scripts in that 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, then you can execute chkconfig fredwilma on.

#!/bin/bash
#
# chkconfig: 345 29 73
# description: mount/unmount my custom bind mounts onto a gfs2 subdirectory
#
#
### BEGIN INIT INFO
# Provides:
### END INIT INFO . /etc/init.d/functions
case "$1" in
start)
# In this example, fred and wilma want their home directories
# bind-mounted over the gfs2 directory /mnt/gfs2a, which has
# been mounted as /mnt/gfs2a
mkdir -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)
$0 stop
$0 start
;; reload)
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac exit 0

Bind Mounts and File System Mount Order的更多相关文章

  1. NFS(Network File System)服务配置和使用

    Sun公司开发NFS (Network File System)之初就是为了在不同linux/Unix系统之间共享文件或者文件夹.可以在本地通过网络挂载远程主机的共享文件,和远程主机交互.NFS共享存 ...

  2. Sharing The Application Tier File System in Oracle E-Business Suite Release 12.2

    The most current version of this document can be obtained in My Oracle Support Knowledge Document 13 ...

  3. 利用 mount 指令解决 Read-only file system的问题

    利用 mount 指令解决 Read-only file system的问题 在linux系统中创建一个文件提示: /application/report/shiwei # touch test.ct ...

  4. linux c语言 rename的用法-rename() does not work across different mount points, even if the same file system is mounted on both

    最近在一个项目上执行文件的搬移功能时发现总是失败,临时录像文件存放于emmc的/tmp/目录下,当录像完成时候则调用rename企图将此文件搬到/mnt/sdcard/mmcblk1p1/(这是外置的 ...

  5. Linux File System

    目录 . Linux文件系统简介 . 通用文件模型 . VFS相关数据结构 . 处理VFS对象 . 标准函数 1. Linux文件系统简介 Linux系统由数以万计的文件组成,其数据存储在硬盘或者其他 ...

  6. HDFS分布式文件系统(The Hadoop Distributed File System)

    The Hadoop Distributed File System (HDFS) is designed to store very large data sets reliably, and to ...

  7. asm和file system之间数据文件的转换

    How to move a datafile from a file system to ASMMoving a datafile from the file system can be achive ...

  8. docker从零开始 存储(三)bind mounts

    使用bind mounts 自Docker早期以来bind mounts 一直存在.与volumes相比,绑定挂载具有有限的功能.使用bind mounts时,主机上的文件或目录将装入容器中.文件或目 ...

  9. Oracle:ORA-09925 and linux Read-only file system error

    今天上午有同事反映应用数据库连接不上:于是排查数据库: [oracle@db ~]$ sqlplus / as sysdba SQL*Plus: Release - Production on Thu ...

随机推荐

  1. 国内强大的API接口文档写作网站showdoc

    传送门:https://www.showdoc.cc/ 思思今天使用了一下,真是非常方便,瞬间爱上呀,哈哈. 赶紧去试试吧...

  2. Zabbix之设置监控主机某个端口并发送邮件告警

    Zabbix可以配置监控主机的某个端口在该端口down之后触发发送告警邮件 一,添加监控项 选择主机 监控项 创建监控项 查看监控图形 二,设置触发器 设置触发器当该监控的端口down时可以发送告警 ...

  3. todolist形式的搜索框,分开组件写的,点击上下键时,框内显示当前选中的内容

    ### 首先  安装react 脚手架 cnpm  install  create-react-app  -g      //只需要在电脑上安装一次就好了,以后不用再下载了 ### 创建项目 crea ...

  4. Direct2D 学习笔记(2)画刷 Brush

    画刷的使用方法 需要包含的文件:<wincodec.h> 需要包含的库: "windowscodecs.lib" 资源网址:    https://docs.micro ...

  5. 【转】Linux用Nasm巧汇编

    看到一篇总结nasm的使用,解决了我的一点问题,下面是原文链接 原文链接:https://blog.csdn.net/zdwzzu2006/article/details/3990502

  6. 使用PowerCLI给ESXi批量设置时间和配置NTP

    在现代的各种业务系统中,时间同步很重要.现在VMware的虚拟化解决方案应用非常广泛,给ESXi宿主机一个统一准确的时间,也给客户机系统一个准确的时间. 生产环境中主机数量少的话倒是可以手动设置,但是 ...

  7. 关于远程链接 redis的坑·

    今天遇到了一个问题,在redis.conf 中 将 bind: 注释掉bind 127.0.0.1 仍然不行 其实是要把bind 127.0.0.1 改为 0.0.0.0 才行 下面附赠详细过程 查看 ...

  8. angular入门 - 环境安装及项目创建

    1.安装node.js 下载,安装,在终端测试安装是否成功:node -v(查看nodejs版本) npm -v(查看npm版本) 下载地址:https://nodejs.org/en/downloa ...

  9. java输入输出 -- Java NIO之套接字通道

    一.简介 前面一篇文章讲了文件通道,本文继续来说说另一种类型的通道 – 套接字通道.在展开说明之前,咱们先来聊聊套接字的由来.套接字即 socket,最早由伯克利大学的研究人员开发,所以经常被称为Be ...

  10. PHP和Memcached - 在PHP中的应用 - Memcached类介绍 - 封装自己的Memcached类库

    1.Memcached类的介绍 详见PHP官方文档:点击访问. 2.封装自己的Memcached类库 <?php namespace Cache\Lib; class MemCache { /* ...