Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Access to original contents of mount point

I have a directory d containing some file f and I mount a drive on directory d. Is there a way of accessing file f without unmounting?

share|improve this question

marked as duplicate by Gilles, jasonwryan, Renan, warl0ck, Mat Sep 29 '12 at 8:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 7 down vote accepted

Yes, bind the original fs to a different position, and you can access it:

mount --bind "$(df -P d | awk '/\/dev/ {print $1}')" /tmp/oldroot

And files would be accessible through /tmp/oldroot/XX/f

share|improve this answer
Nice trick! I would have expected the answer: “No, it's shadowed by the other file system unless you unmount it.” – Marco Sep 28 '12 at 9:20
@Marco: The directory in the original mount is shadowed, but bind mounting the device itself somewhere else makes everything on it available elsewhere. – Ignacio Vazquez-Abrams Sep 28 '12 at 15:18
This does not appear to work on redhat/centOS 7. It works on 6.x. In 7 it will just show the mounted dir. – MikeKulls Feb 1 at 0:50

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