mount --bind 的妙用
来源:互联网 发布:mac三国志13修改器 编辑:程序博客网 时间:2024/06/10 20:42
mount --bind 的妙用
在固件开发过程中常常遇到这样的情况:为测试某个新功能,必需修改某个系统文件。而这个文件在只读文件系统上(总不能为一个小小的测试就重刷固件吧),或者是虽然文件可写,但是自己对这个改动没有把握,不愿意直接修改。这时候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
1 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、)
- 挑7
- 【Android测试】Uiautomator——API详解
- poj2223Frogger【二分】
- 孙鑫lesson20 hook &database
- map双键-值对及特殊键值对
- mount --bind 的妙用
- MJExtension框架中模型里包含模型的问题
- poj 2833 堆排序
- zookeeper知识点三(获取子节点)
- MonkeyRunner API使用说明-------------第3章
- QT 学习之路 图片显示
- Android Studio 每次启动都默认打开项目--解决方法
- 解决PHP之 Allowed memory size of xxx bytes exhausted
- java中生成伪随机数的一些简单实现方法