Linux bind mount file

All about bind mounts in Linux

Bind mounts grants the users access to a directory by binding the directory to the same user’s home directory. Since Linux version 2.4.0 you can remount a section of the file hierarchy in another location with the command:

After this, the same file content is accessible in two different places. You can also choose to remount a single file.
Rather than mounting a device on a specific path, bind mounts grant you the ability to mount one path into another.

For instance, suppose you have a small /var and a huge /opt partition. In this case, you will require additional space for the growing log files.

Let’s see what the Support Team suggests in this scenario:
First, you need to shut down services responsible for writing to the log file. Then:

mv /var/log /opt/var_log mkdir /var/log mount -o bind /opt/var_log /var/log

This will be reflected when you run the mount command seen below:

# mount | grep var /opt/var_log on /var/log type none (rw,bind)

By this point, you can restart the services stopped previously.
In case you want this to carry on across reboots, update the /etc/fstab also with bind mount.

# /etc/fstab /opt/var_log /var/log none bind 0 0

This trick comes in handy until a long-term fix is in place.

Additional details about bind mounts in Linux

Bind mounts in Linux allow you to mount a previously-mounted system to a different location within the same file system. Additionally, bind mounts are used to restrict user access to specific parts of a website. This is done by replicating that website’s directory to the user’s home directory.
You can configure a bind mount with the command:

mount --bind /path/to/domain /path/to/home/directory

Run the following command to add a bind mount to the file system table:

/path/to/domain /path/to/home/directory none bind,nobootwait 0 0

In case the nobootwait is not present in the fstab entry, you will get a message like this:

Continue to wait; or Press S to skip mounting or M for manual recovery.

Adding nobodywait to the fstab configuration’s option section makes sure that the system boots even when the bind mount directory is removed from the system.

Читайте также:  Pst to eml linux

[Looking for a helping hand? We are at your service.]

Conclusion

In short, we learned all about bind mounts in Linux today. With our Support Team on your side, you have nothing to worry about.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

Источник

Оцените статью
Adblock
detector