Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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.

1 Answer 1

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

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