Pregunta de Linux Administration #019e3987
Which of the following is correct when talking about mount points?
Every existing directory can be used as a mount point.
Only empty directories can be used as a mount point.
Directories need to have the SetUID flag set to be used as a mount point.
Files within a directory are deleted when the directory is used as a mount point.
Explicación Oficial / Explicaciones de la Comunidad
A mount point is a directory in the filesystem hierarchy where a separate filesystem is attached. The correct statement is that every existing directory can be used as a mount point. This is because the mount command attaches a filesystem to any specified directory, regardless of its contents or permissions (though the user must have appropriate permissions to perform the mount).
How it Works
When you run mount /dev/sdb1 /mnt/data, the kernel associates the filesystem on /dev/sdb1 with the directory /mnt/data. Any existing files or subdirectories in /mnt/data become inaccessible until the filesystem is unmounted; they are not deleted. The directory itself must exist before mounting.
Why the Correct Statement is Right
- Every existing directory can be used as a mount point. This is true because the
mountcommand does not impose restrictions on the directory's contents or attributes. Even a non-empty directory can serve as a mount point; its existing files are simply hidden while the mount is active.
Why the Incorrect Statements are Wrong
- Only empty directories can be used as a mount point. This is false. While it is common practice to use empty directories to avoid hiding files, the system does not require emptiness. Non-empty directories work fine; the existing files are temporarily obscured.
- Directories need to have the SetUID flag set to be used as a mount point. This is false. The SetUID permission (chmod u+s) is unrelated to mounting. Mount points require no special flags; any directory can be used.
- Files within a directory are deleted when the directory is used as a mount point. This is false. Mounting does not delete files. The files remain on the underlying filesystem and reappear when the mount is removed.