I just accidentally mounted a new drive to a folder that already contained files. I don't care about them and have them somewhere else, but that folder appears empty now. I'm curious what happened to the files. Are they simply deleted by Linux?
Just "shadowed" and will be there again when unmounted. :)
In fact the files are "there" intact and if you need to reach them right away, w/o unmounting, this can be worked-around with so-called
It works (so) because when you ask kernel to mount a filesystem to some mountpoint, kernel treats that mountpoint as a "view port" to filesystem you're mounting, so it's expected you shall see mounted FS content there.
But this is not the only way how those FSes "layers" can be combined to single view. There's so called "union mount" approach (it's funny to know that this "a central concept in Plan 9", BTW). On Linux you could use Aufs, which never made its way into mainline kernel, or, currently (since 3.18), OverlayFS — it did.
The newly mounted filesystem is like an overlay which hides part of the initial filesystem. There are trick to access the files, like the bind mount as described by poige. On Linux I personally like the fact that you can mount a filesystem more than once on different mount points. So you can perfectly well mount the root filesystem on