If I attempt to mount a folder that already has files in it, does linux give me an error message or go ahead and show both the mounted filesystem and the files that were already in the folder?
When you mount a filesystem on a directory
/mount-point, you can no longer access files under
/mount-point directly. They still exist, but
/mount-point now refers to the root of the mounted filesystem, not to the directory that served as a mount point, so the contents of this directory cannot be accessed, at least in this way. For example:
# touch /mount-point/somefile # ls /mount-point/somefile /mount-point/somefile # mount /dev/something /mount-point # ls /mount-point/somefile ls: cannot access /mount-point/somefile: No such file or directory
There are ways to get a merged view of the mounted filesystem and the data that was already present, but you need an extra layer called a union filesystem.
Under Linux, there is a way to see the hidden files. You can use
mount --bind to get another view of the filesystem where the mount point is. For example
mount --bind / /other-root-view
You'll see all the files in the root filesystem under
# cat /other-root-view/etc/hostname darkstar
/mount-point will now be accessible as
/other-root-view/mount-point, and since
/other-root-view/mount-point is not a mount point, you can see its contents there:
# ls /mount-point/somefile ls: cannot access /mount-point/somefile: No such file or directory # ls /other-root-view/mount-point/somefile /other-root-view/mount-point/somefile