📝 File System Mounting in Operating System
Connecting a File System to the Directory Hierarchy
File-system mounting is the process of making a storage volume or remote file system accessible through an operating system's directory hierarchy. The kernel attaches the root directory of the selected file system to an existing directory called the mount point. This operation connects two independently organised file-system structures without physically copying or merging their files. After mounting, applications can access the attached file system through ordinary pathnames, just as they access directories on the original file system.
Why Storage Volumes Need Mount Points
A storage device, disk partition, removable drive, or remote file system may contain its own independent directory structure. However, that structure is not automatically reachable through the ordinary pathnames of the operating system's existing directory hierarchy. Mounting connects the root of the separate file system to a selected directory, allowing its files to be accessed through the existing namespace. For example, a USB file system can be made accessible under /mnt/usb, while a network file system can be attached to a directory used for shared resources.
This arrangement allows several file systems to coexist without requiring their directory structures to be physically combined. Applications continue to use normal file operations and pathnames, while the operating system determines which mounted file system contains the requested directory or file. Mounting therefore provides a consistent access method for storage devices that may use different file-system types. It is a logical attachment operation, not a process that copies all files into the mount-point directory.
Mount System Call and Filesystem Attachment
The administrator or system service supplies the storage source and the directory where the file system must be attached. In Unix and Linux systems, a mount command requests the operation through the kernel's mounting interface. The kernel checks the mount point, identifies or receives the file-system type, and verifies that the selected source contains a recognisable file system. The appropriate file-system driver reads the required metadata and establishes the file system's internal structures before the attachment is completed.
After successful validation, the kernel records the mount relationship in its mount table or equivalent internal mount structures. The mounted file system's root directory is associated with the selected mount point. During pathname resolution, the kernel follows the existing directory hierarchy until it reaches that mount point, then continues lookup from the root of the mounted file system. For example, after mounting a volume at /mnt/data, the pathname /mnt/data/report.txt is resolved inside the attached file system rather than through the original contents of the mount-point directory.
Unmounting reverses the attachment by removing the active mount relationship. The operating system must ensure that the file system is no longer being used in a way that prevents detachment. Open files, a process using a directory inside the mounted file system as its current working directory, or other active references can cause an ordinary unmount operation to fail. Linux may report the EBUSY error when a file system is busy.
Mounting a Separate Storage Volume
Suppose a Linux computer has a partition containing an existing file system on /dev/sdb1. The administrator wants its contents to become accessible through the /mnt/data directory. After ensuring that the mount-point directory exists, the administrator can issue the command mount /dev/sdb1 /mnt/data. The kernel validates the file system and attaches its root directory at that location. This example assumes that /dev/sdb1 already contains a recognised file system; mounting does not create or format one.
After mounting, a file named report.txt stored in the attached file system can be accessed through /mnt/data/report.txt. If the /mnt/data directory previously contained a file such as old.txt, that original entry becomes hidden while the other file system is mounted over it. It is neither copied into the new file system nor permanently deleted. When the administrator safely executes umount /mnt/data, the attachment is removed and the original contents of the mount-point directory become visible again.
The pathname demonstrates how the operation works: the operating system first resolves /, then reaches the mnt directory and the data mount point. At that boundary, pathname lookup switches to the root directory of the attached file system. It then searches that file system for report.txt. This transition allows a file on a separate storage volume to appear as an ordinary file within the system's directory hierarchy.
Unified Access and Safe Unmounting
Mounting provides a unified namespace for internal disks, additional partitions, USB drives, optical media, and network file systems. Remote file systems can also be mounted through network protocols such as NFS or SMB, allowing users to access server-hosted directories through local-looking pathnames. Operating systems may mount some file systems automatically during startup. On Linux, the root file system is mounted during the boot process, while additional file systems can be configured for automatic mounting through /etc/fstab or system services.
Mount options control how an attached file system behaves. For example, the ro option requests read-only access, noexec restricts execution of programs from that file system, and nosuid prevents set-user-ID and set-group-ID effects from being applied to programs on it. These options can help control access to removable or externally supplied storage. The actual options available depend on the operating system and file-system type.
Before removing a storage device, the user should unmount its file system so that outstanding operations can finish and filesystem changes can be safely handled. A busy mount point may prevent ordinary unmounting because files remain open, processes are still using the mounted directory, or other active references exist. Some operating systems also use drive letters to identify volumes; modern Windows versions can additionally attach volumes to directory locations. The exact mounting interface therefore differs between operating systems, even though the purpose of making a file system accessible remains similar.
Common Misconceptions About Mount Points
“Mounting physically copies every file into the mount directory” is incorrect because mounting logically attaches the root of another file system to an existing directory. “A mount point must always be empty” is also too absolute. An empty directory is commonly chosen for clarity, but some operating systems allow mounting over a directory that already contains entries; those original entries become hidden while the mounted file system is active. “The hidden files are deleted” is incorrect because unmounting can reveal the original directory contents again.
“Connecting a storage device automatically makes every file accessible through the main directory hierarchy” is incorrect because its file system must be mounted or otherwise made available through the operating system's storage interface. “Mounting and formatting mean the same thing” is incorrect because formatting creates file-system structures, whereas mounting attaches an existing file system to a directory hierarchy. “A mounted file system can always be detached immediately” is also incorrect because active files, processes, or references can prevent a safe unmount operation.
Exam Focus: Mount Points and Pathname Resolution
Questions about file-system mounting commonly test the definition of a mount point, the role of the mounted file system's root directory, and the way separate directory structures become accessible through one hierarchy. Be able to explain the difference between the state before mounting and the state after mounting. In particular, identify which directory is used as the mount point, which file-system root is attached there, and how the kernel changes pathname lookup when a path crosses the mount point.
Also distinguish the source device from the mount-point directory and explain why the operating system checks the file-system format before completing the attachment. Remember that mounting does not format a partition or copy its files. Existing mount-point contents may become hidden, and an ordinary unmount may fail when the mounted file system is still in use. Additional questions may examine mount-table records, automatic mounting at boot, remote file systems, and options such as ro, noexec, and nosuid.
Key Terms of File-System Mounting
- Mounting - Logically attaches a file system to an existing directory hierarchy.
- Mount point - Existing directory at which another file system is attached.
- Mounted file system - File system currently connected to the directory hierarchy.
- Root directory - Top-level directory of a file system that becomes accessible through its mount point.
- Mount table - Kernel-maintained information about active file-system attachments.
- Pathname resolution - Process of following directory components to locate a file or directory.
- Unmounting - Safely detaches a mounted file system from the directory hierarchy.
- Mount options - Settings that control access and behaviour of an attached file system.
- Automatic mounting - Mounting configured to occur during system startup or when a resource is accessed.
📝 All File System Mounting in Operating System MCQs
Q1. What term describes the unused space that remains in the last allocated block of a file because the file size is not an exact multiple of the block size?
📖 Explanation: The correct answer is Internal fragmentation because the leftover bytes in the final block cannot be used for other data, which is exactly what internal fragmentation means. External fragmentation refers to gaps between allocated blocks, not space inside a block. Slippage and padding are unrelated concepts. Recognizing internal fragmentation helps students understand why some storage appears wasted even though the file fits within its allocated blocks.
Q2. In sequential-access files, what is the primary role of the file pointer after a read operation?
📖 Explanation: The file pointer tracks the current I/O location, so after a read it points to the next byte or record to be processed. This enables the system to know where to continue reading or writing. Options A and B describe different actions, and D is unrelated. Understanding the pointer’s role clarifies how sequential access progresses through a file.
Q3. Why does increasing the block size generally increase internal fragmentation in a file system?
📖 Explanation: Larger block sizes allocate more space for each block, so the remainder of the last block is often bigger, leading to greater internal fragmentation. The other options describe unrelated effects: reducing file count, compression, or external fragmentation, none of which directly explain the waste inside a block. This concept explains why designers must balance block size against wasted space.
Q4. A file of 3,000 bytes is stored on a disk with a block size of 1,024 bytes. How many bytes are wasted due to internal fragmentation?
📖 Explanation: Three blocks are needed (3 × 1,024 = 3,072 bytes). The file occupies 3,000 bytes, leaving 3,072 − 3,000 = 72 bytes unused, which is internal fragmentation. Option A (48) and C (96) are incorrect calculations, and D (120) overestimates the waste. Knowing how to compute wasted space lets students evaluate storage efficiency for different block sizes.
Q5. How does the tape model influence the design of sequential-access methods for modern file systems?
📖 Explanation: The tape model treats a file like a linear stream, so sequential-access methods read records in order and rely on a moving file pointer. This design simplifies implementation and matches many applications. Options A and C impose constraints not inherent to the tape model, and D is false because buffering remains important for performance. The model’s influence explains why sequential APIs are still common.
Q6. A database stores records averaging 1,800 bytes. To minimize internal fragmentation, which block size should an administrator choose?
📖 Explanation: Choosing a block size just larger than the average record (2,048 bytes) ensures each record fits in a single block, limiting waste to the difference between block size and record size (≈248 bytes). Smaller blocks would require multiple blocks per record, increasing total waste, while a larger block (4,096 bytes) would double the unused space. This decision illustrates the trade‑off between block size and fragmentation.
Q7. Which statement correctly distinguishes internal fragmentation from external fragmentation?
📖 Explanation: Internal fragmentation is the unused space inside a block that has been allocated, whereas external fragmentation refers to free gaps between allocated blocks on the disk. The other options mischaracterize causes or scope: variable‑length records affect allocation strategy, not fragmentation type; sequential files can still suffer external fragmentation; and larger blocks often increase, not eliminate, internal fragmentation.
Q8. A program using sequential access wants to skip forward two records after reading the third record. Which operation best describes this action?
📖 Explanation: The seek operation with n = 2 tells the system to move the file pointer ahead by two records, effectively skipping them. Using read_next() twice would also work but is less direct; write_next() does not affect reading, and reset() would return to the file start. This scenario tests understanding of how to programmatically move past records in a sequential file.
Q9. How does internal fragmentation impact overall storage efficiency on a disk with many small files?
📖 Explanation: When many small files are stored, each file’s final block can contain a large unused portion, cumulatively reducing usable storage and lowering efficiency. The other options are inaccurate: internal fragmentation does not consolidate free space, it does affect efficiency, and it is more pronounced for small files, not just large ones. Recognizing this effect guides decisions about block size for mixed workloads.
Q10. Three files have sizes 2,500 bytes, 4,700 bytes, and 9,200 bytes. If the disk block size is 1,024 bytes, what total wasted space results from internal fragmentation?
📖 Explanation: File 1 needs 3 blocks (3 × 1,024 = 3,072) → waste = 572 bytes. File 2 needs 5 blocks (5 × 1,024 = 5,120) → waste = 420 bytes. File 3 needs 9 blocks (9 × 1,024 = 9,216) → waste = 16 bytes. Total waste = 572 + 420 + 16 = 1,008 bytes. The other options result from mis‑adding or mis‑calculating block counts. This calculation shows how fragmentation adds up across many files.
Q11. After performing write_next() to append 600 bytes to a file that currently ends at byte offset 2,048, where will the file pointer be positioned?
📖 Explanation: The write_next() call adds 600 bytes, moving the end of the file from 2,048 to 2,648 bytes; the file pointer is automatically placed at the new end. Option A leaves the pointer unchanged, B miscalculates the offset, and D adds an extra 552 bytes. Understanding pointer movement after writes is essential for correct sequential file handling.
Q12. Which of the following best explains the trade‑off between larger block sizes and internal fragmentation when designing a file system for a workload dominated by large multimedia files?
📖 Explanation: Larger blocks mean fewer I/O operations because each read/write transfers more data, which benefits large multimedia files. However, for any small files that exist, the last block can waste more space, increasing internal fragmentation. The other statements are false: larger blocks do not eliminate fragmentation, they do not improve transfer rates for large files compared to optimal sizing, and they do not directly cause external fragmentation.
Q13. A system stores 10,000 files whose sizes follow a uniform distribution between 200 bytes and 2,000 bytes. Which block size minimizes expected internal fragmentation?
📖 Explanation: For a uniform distribution, the expected waste per file equals half the block size. To minimize waste, the smallest practical block size should be chosen; 512 bytes is the smallest common size among the options, yielding an expected waste of 256 bytes per file. Larger block sizes would double or quadruple the average waste. This reasoning illustrates how statistical file size patterns guide block‑size decisions.
Q14. A sequential file allows skipping backward by one record only. If a program reads record 5, then skips back one record, which record will be read next?
📖 Explanation: Skipping back one record moves the file pointer to the previous record, so after reading record 5 and moving back, the next read returns record 4. Options B, C, and D ignore the backward movement or assume forward skipping, which contradicts the given limitation. This scenario tests understanding of pointer manipulation in constrained sequential access.
Q15. Why might an operating system still provide a sequential‑access interface for files stored on random‑access media?
📖 Explanation: Sequential access matches the natural order of many workloads (e.g., log processing) and allows the OS to implement efficient read‑ahead buffering and caching, simplifying program design. Random‑access media can still perform random reads, so option B is false; sequential access does not inherently reduce wear or force contiguity, making C and D incorrect. Recognizing this rationale explains why both access methods coexist.
Q16. A disk has a capacity of 500 GB and uses a block size of 4 KB. If internal fragmentation wastes an average of 1 KB per file and there are 1 million files, what fraction of the disk capacity is lost to internal fragmentation?
📖 Explanation: Total waste = 1 KB × 1,000,000 = 1,000,000 KB = 1,000 MB = 1 GB. Fraction of 500 GB = 1 GB ÷ 500 GB = 0.002 = 0.2 %. The other percentages result from mis‑calculating the waste or total capacity. This problem shows how even small per‑file waste can add up across many files, influencing storage planning.
Q17. A program reads the first 3 records of a sequential file, then calls reset(). What will be the next record read?
📖 Explanation: The reset() operation returns the file pointer to the beginning of the file, so the subsequent read retrieves the first record again. Option B would be correct without reset, C repeats the last read record, and D incorrectly assumes the file ends. Understanding reset behavior is crucial for correctly restarting processing of sequential data.
Q18. When a sequential‑access system permits skipping forward only one record at a time, what limitation does this impose on algorithm design?
📖 Explanation: Limiting skips to one record forces programs to handle data in order or maintain their own buffers if they need to look ahead, effectively restricting algorithmic flexibility. The other statements misrepresent the effect: skipping one record does not entirely block random access, does not remove file pointers, and does not enable unlimited backward jumps. Recognizing this constraint helps developers design efficient sequential algorithms.
Q19. If a file of 1,949 bytes is stored using 256‑byte blocks, how many bytes are wasted due to internal fragmentation?
📖 Explanation: The file requires ceil(1,949 ÷ 256) = 8 blocks, giving 8 × 256 = 2,048 bytes allocated. Waste = 2,048 − 1,949 = 99 bytes. Options B, C, and D are incorrect calculations. Knowing how to compute waste for a given block size lets students evaluate the impact of block‑size choices on storage efficiency.
Q20. How does sequential access enable more effective read‑ahead buffering compared to random access?
📖 Explanation: When access is sequential, the system knows that the next record follows the current one, so it can load subsequent blocks into memory before they are requested, reducing latency. The other options are false: sequential access does not disable caching, does not demand full‑file reads, and does not cause random head movement. This principle underlies performance optimizations for streaming data.
Q21. A file currently ends at byte offset 5,120. A program performs three consecutive write_next() calls each writing 300 bytes. What will be the final file pointer offset?
📖 Explanation: Each write adds 300 bytes, so three writes add 900 bytes total. Adding this to the original offset of 5,120 bytes yields 6,020 bytes, which is where the file pointer ends. Options A and B underestimate the total added bytes, while D adds an extra 100 bytes. Understanding cumulative pointer movement after multiple writes is essential for correct file size tracking.