Mount vs bind mount

From HPCWIKI
Jump to navigation Jump to search

In Linux systems, we can mount a device in a directory using the mount command. This allows us to access the device’s filesystem

$ findmnt --real
TARGET                SOURCE    FSTYPE  OPTIONS
/                     /dev/sda5 ext4    rw,relatime,errors=remount-ro
├─/sys/kernel/tracing tracefs   tracefs rw,nosuid,nodev,noexec,relatime
└─/boot/efi           /dev/sda1 vfat    rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro

However, we can also mount a directory on another directory by using the mount command with the --bind parameter.[1]


bind mount source can be any directory,

  • If the source directory is a device’s mount point, then the whole device is bind-mounted on the destination directory.
  • If instead, the source is a device’s subdirectory, then the device is bind-mounted starting from that subdirectory.


When we use the --bind parameter, mount points inside the source directory aren’t remounted. So, if we want to bind mount a directory and all submounts inside that directory, we have to use the --rbind parameter instead. After doing a bind mount, we won’t have access to the original content in the target directory.

Usage of bind mount

bind mount enable to access files hidden by a mount point and allows us to access files outside of chroot environment. This article shows the usage of bind mount

References