Mounting directories and file systems to more than one location


While reading through the mount(8) manual page on one of my RHEL4 servers this week, I came across the “–bind” option. This nifty option allows you to mount a directory in the file system namespace to a second location. The following example shows how to use this option to mount the directory /home/data to a second location, /opt/data:

$ mount --bind /home/data /opt/data

Once the bind mount is created, /opt/data will look and feel just like /home/data, and will show as a mounted file system when the mount utility is run:

$ mount | egrep '(bind|ext3)'
/dev/sda1 on / type ext3 (rw) /dev/sda3 on /home type ext3 (rw) /home on /opt/data type none (rw,bind)

This is a nifty option, and saved me having to recreate a file system on one of my servers. :)

This article was posted by Matty on 2007-05-01 19:08:00 -0400 -0400