The use of mount -- bind

Source: Internet
Author: User

The use of mount -- bind often encounters the following situation during Firmware Development: to test a new function, you must modify a system file. This file is stored in a read-only File System (you cannot refresh the firmware for a small test), or although the file can be written, you are not sure about the change and do not want to modify it directly. In this case, mount -- bind is your helper. Assume that the file we want to change is/etc/hosts. perform the following steps: 1. Put the new hosts file under/tmp. Of course, it can also be placed on a hard disk or a USB flash disk. 2. mount -- bind/tmp/hosts/etc/hosts test is complete. Run umount/etc/hosts to disconnect the binding. What if I need to add an exports file under/etc? This file does not exist and cannot be directly bind. We have two methods: Method 1: bind the entire/etc directory, copy/etc # cp-a/etc/tmp # mount -- bind/tmp/etc before binding. At this time, the/etc directory is writable, the modification will not be applied to the original/etc directory, so you can test it with confidence. Method 2: mount ramfs to/etc. Also, copy/etc to mount ramfs # mkdir/tmp/etc # mount-t ramfs none/tmp/etc to copy/etc, we cannot use cp-a here. Instead, use tar # cd/etc # tar cf -. | (cd/tmp/etc; tar xf-) # cd/overwrite/etc # mount -- move/tmp/etc after testing, remember umount/etc

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.