100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is File System Mounting?

Learn what file system mounting is, how mount points work, and how Unix mounting differs from Windows, with OS interview questions.

mediumQ119 of 224 in Operating Systems Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

File system mounting is the process of attaching a file system on a partition or device to a specific point (the mount point) in the operating system’s single, unified directory tree, making its files and directories accessible at that path as though they were part of one continuous file system.

Before a file system is mounted, the OS has no way to reference the files stored on that device through the normal directory hierarchy; the mount operation reads the file system’s superblock (its metadata about layout, size, and structure) and links the root of that file system into the chosen directory (the mount point) in the existing tree — for example, mounting a USB drive at /media/usb on Linux makes its contents appear under that path. Unlike Windows, which assigns each file system its own drive letter (C:, D:), Unix-like systems present everything under a single root (/), so multiple physical or logical devices, including remote network shares (NFS, SMB) and virtual file systems (procfs, tmpfs), can all be transparently woven into one tree via mounting. The kernel maintains a mount table tracking which device is mounted where, and unmounting reverses the process, flushing any pending writes and detaching the device so its data is no longer visible in the tree — attempting to unmount a device with open file handles or a process using it as a working directory will normally fail until those references are released. Mount options can additionally control behavior per mount, such as read-only, no-execute, or specific caching policies, independent of the underlying device’s defaults.

  • Presents multiple physical or virtual file systems as one unified tree
  • Lets removable media, network shares, and virtual FS integrate transparently
  • Enables per-mount access policies (read-only, no-exec) independent of the device
  • Clean unmount flushes writes and safely detaches without data loss

AI Mentor Explanation

File system mounting is like grafting a newly acquired training facility onto a club’s existing campus map at a specific gate, so players can walk from the main ground straight into the new facility without needing a separate address. Before the graft, the new facility exists but is not reachable from the campus map at all. Detaching it later (unmounting) removes that gate connection cleanly, but only once nobody is actively training inside it.

Step-by-Step Explanation

  1. Step 1

    Read the superblock

    The OS reads the target file system’s superblock to learn its type, layout, and size.

  2. Step 2

    Attach at the mount point

    The file system’s root directory is linked into the existing directory tree at the chosen mount point path.

  3. Step 3

    Update the mount table

    The kernel records the device-to-mount-point mapping and any mount options (read-only, no-exec, etc.) in its mount table.

  4. Step 4

    Unmount (reverse)

    On unmount, pending writes are flushed and the file system is detached; this fails if files or working directories on it are still open.

What Interviewer Expects

  • Clear definition of mounting as attaching a file system to a directory tree path
  • Contrast with Windows drive-letter model vs Unix single-tree model
  • Awareness that unmounting can fail while files are still open
  • Knowledge that virtual and network file systems can be mounted too (procfs, NFS)

Common Mistakes

  • Confusing mounting with formatting a file system
  • Thinking a mount point must always be an empty directory forever after (files placed there are hidden, not deleted)
  • Forgetting that unmounting can fail due to open file handles
  • Assuming only physical disks can be mounted, ignoring network and virtual file systems

Best Answer (HR Friendly)

File system mounting is how the operating system connects a drive, partition, or network share into the regular folder structure you browse every day, at a specific folder called the mount point. Before mounting, that storage exists but you cannot see or open its files through the normal file browser; after mounting, its contents just appear as if they were always part of the same folder tree.

Code Example

Mounting and unmounting a file system on Linux
#include <sys/mount.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

int mount_filesystem(void) {
    /* mount(source, target, filesystemtype, mountflags, data) */
    if (mount("/dev/sdb1", "/mnt/data", "ext4", MS_NOEXEC, NULL) != 0) {
        fprintf(stderr, "mount failed: %s\n", strerror(errno));
        return -1;
    }
    printf("Mounted /dev/sdb1 at /mnt/data (no-exec)\n");
    return 0;
}

int unmount_filesystem(void) {
    if (umount("/mnt/data") != 0) {
        /* fails with EBUSY if files are open or it is a working directory */
        fprintf(stderr, "unmount failed: %s\n", strerror(errno));
        return -1;
    }
    printf("Unmounted /mnt/data\n");
    return 0;
}

Follow-up Questions

  • How does Unix’s single-tree mount model differ from Windows drive letters?
  • What happens if you try to unmount a file system with open file handles?
  • What is a virtual file system like procfs, and how is it mounted?
  • How does mounting a network file system like NFS differ from mounting a local disk?

MCQ Practice

1. What does mounting a file system accomplish?

Mounting links a file system’s root into the OS directory tree at a mount point, making its files accessible through that path.

2. Why might an unmount operation fail?

The kernel will not detach a file system that still has active references, such as open file handles or a process working inside it.

3. Which of these can be mounted, besides physical disk partitions?

Network file systems and virtual/pseudo file systems can also be mounted into the directory tree just like local partitions.

Flash Cards

What is file system mounting?Attaching a file system to a mount point in the OS directory tree so its contents become accessible.

How does Unix mounting differ from Windows drive letters?Unix presents everything under one root tree via mount points; Windows assigns separate drive letters.

Why can unmounting fail?If files are still open or a process’s working directory is on that file system.

Name a virtual file system that can be mounted.procfs (process info) or tmpfs (RAM-backed storage).

1 / 4

Continue Learning