16

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?

0

1 Answer 1

15

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

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.