Forrest logo
back to the mount tool

mount:tldr:e9668

mount: Mount a directory to another directory.
$ mount --bind ${path-to-old_dir} ${path-to-new_dir}
try on your machine

The command is used to create a bind mount in Linux.

A bind mount is a way to associate two directories located in different locations on the file system, but make them accessible as if they were the same directory. It essentially allows you to create a mirror or link between two directories.

The command syntax is as follows:

mount --bind ${path-to-old_dir} ${path-to-new_dir}

${path-to-old_dir} represents the existing directory that you want to bind to a new location. ${path-to-new_dir} represents the directory where you want to create the new bind mount.

For example, let's assume you have an existing directory called /home/user/old_dir and you want to create a bind mount to a new directory called /mnt/new_dir. The command to achieve this would be:

mount --bind /home/user/old_dir /mnt/new_dir

Once the bind mount is created, any changes made to either /home/user/old_dir or /mnt/new_dir will be synchronized, as they point to the same underlying data. This can be useful in situations where you want to access files from different locations, but treat them as if they were in the same directory.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mount tool