mount --bind 的妙用
来源:互联网 发布:php编译curl 编辑:程序博客网 时间:2024/05/19 17:23
转自:http://www.cnitblog.com/gouzhuang/archive/2010/04/21/mount_bind.html
在固件开发过程中常常遇到这样的情况:为测试某个新功能,必需修改某个系统文件。而这个文件在只读文件系统上(总不能为一个小小的测试就重刷固件吧),或者是虽然文件可写,但是自己对这个改动没有把握,不愿意直接修改。这时候mount --bind就是你的好帮手。
假设我们要改的文件是/etc/hosts,可按下面的步骤操作:
1. 把新的hosts文件放在/tmp下。当然也可放在硬盘或U盘上。
2. mount --bind /tmp/hosts /etc/hosts
测试完成了执行 umount /etc/hosts 断开绑定。
如果我需要在/etc下面增加一个exports文件怎么办?原来没有这个文件,不能直接bind。我们有两个方法:
方法1:绑定整个/etc目录,绑定前先复制/etc
# cp -a /etc /tmp
# mount --bind /tmp/etc /etc
此时的/etc目录是可写的,所做修改不会应用到原来的/etc目录,可以放心测试。# mount --bind /tmp/etc /etc
方法2:挂载ramfs到/etc,同样要先复制/etc
挂载ramfs
# mkdir /tmp/etc
# mount -t ramfs none /tmp/etc
复制/etc,这里我们不能用cp -a,改用tar
# cd /etc
# tar cf - . |(cd /tmp/etc; tar xf -)
# cd /
覆盖/etc
# mount --move /tmp/etc /etc
测试完了记着 umount /etc # mkdir /tmp/etc
# mount -t ramfs none /tmp/etc
复制/etc,这里我们不能用cp -a,改用tar
# cd /etc
# tar cf - . |(cd /tmp/etc; tar xf -)
# cd /
覆盖/etc
# mount --move /tmp/etc /etc
0 0
- mount --bind 的妙用
- mount --bind 的妙用
- mount --bind 的妙用
- 【转】mount --bind 的妙用
- 关于mount --bind的理解。
- mount --bind
- linux下mount bind的用法
- mount命令里的bind选项
- mount --bind和硬连接的区别
- linux 修复grub及mount 命令的妙用
- 使用Mount bind时需要注意的权限问题
- mount --bind 绑定挂载
- Data Volume 之 bind mount
- mount --bind挂载功能,避免ln -s链接的不足。
- 深入浅出Javascript中apply、call和bind以及它们的妙用
- Linux中的chroot,Bind Mount以及Mount Namespaces
- chroot, mount --bind and mount namespace (by quqi99)
- mount参数详解逐步更新(--bind、)
- [笔试积累]9-11日
- Lession 8 注解和异常
- CodeForces-96A-Football
- lightOJ1339线段树
- Java线程:线程栈模型与线程的变量
- mount --bind 的妙用
- WPF中MouseLeftButtonDown失灵的问题
- 结构体用于字模
- Java线程:线程的同步与锁
- Vs2013未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage”包 , GUID应包含带4个短划线的32位数。
- Java线程:线程的交互
- jexcleapi-数据导成excle表格
- struts2通配符的使用
- 关于android报错 libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused)