0
mkdir /home

then we mount something on /home.

Say /home already contains files.

What happen to the old files after a new drive is mounted to that directory?

5

The mount will hide any existing files in the directory used as a mountpoint. Nothing happens to the files themselves.

If you want to access the hidden files without unmounting /home, you can bind mount the underlying directory at another mountpoint:

$ mount --bind / /mnt

Now /mnt/home/ contains the files hidden by the /home mount.

| improve this answer | |
  • So ideally the directory for mounting should be empty? – user4951 Sep 30 '13 at 7:30
  • Typically the mountpoint is empty prior to the mount, but it doesn't really matter unless you need to access any files that would be hidden by the mount. Keep in mind that the the disk space used by the hidden files is still reported by df (which accesses the used block counts from the file system), but wouldn't show up in du output (as du wouldn't be able to access the files to get their size). – Thomas Nyman Sep 30 '13 at 7:35
0

File stays there. Nothing happens to them. It is just hidden beneath the new layer.

But if you are looking for solution to see both file

a. directory /home content

b. mountpoint /home content

at the same time then you need to study aufs

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.