Bind Mounts and File System Mount Order
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:
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 owninit
scripts.A file system with its own
init
script is mounted later in the initialization process, after the file systems in thefstab
file.大意是:在初始化过程中,一个带有自身init脚本的文件系统会被挂载,不过,这要在fstab这个文件中所列出的文件系统被挂载之后。也就是说,挂载次序慢于fstab中的文件系统
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:
Mount local file systems that are required for the bind mount.
Bind mount the directory on which to mount the GFS2 file system.
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 2673 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
最新文章
- JavaScript 开发技巧 || 返回有效值
- Rust初步(三):使用atom搭配racer进行rust编程
- ubuntu 搭建开发环境
- CLR via C# 随记
- XML文件的生成与读取
- Error: Cannot find module 'express'
- Java内存区域与内存溢出异常(二)
- IIS7 发布mvc3.0
- Linux bash中的变量分类
- BZOJ1015 [JSOI2008]星球大战starwar(并查集)
- kafka资料
- Python的__getattr__和__getattribute__
- 收集nodejs经典组件:
- vue.js小总结
- vue自制switch滑块
- rbac models
- kafka实战读书笔记
- Perl中命令行参数以及打开管道文件
- 移动端 meta 必备
- CF232C Doe Graphs
热门文章
- 【数据库开发】学习Redis从这里开始
- 【计算机视觉】Selective Search for Object Recognition论文阅读1
- discuz 访问 Discuz! Database Error(2002) notconnect
- 打印网页js
- 用ExtentReports美化你的测试报告
- 关于php发送邮件(PHPmailer)的傻瓜式操作
- centos7.6编译安装php7.3
- python中的 __inti__ 和 __new__ 方法的区别
- docker 实践二:操作镜像
- go 构造切片slice