Mounting and Unmounting File Systems

  1. Mount
  2. Unmount

Mounting a File System

The mount system call connects the file system in a specified section of a disk to the existing file system hierarchy, and the unmount system call disconnects a file system from the hierarchy. The mount system call allows users to access data in a disk section as a file system instead of a sequence of disk blocks.
To use mount you type:

mount(special pathname, directory pathname, options)
Special pathname is the name of the device special file of the disk section containing the file system to be mounted, the directory pathname is the directory in the existing hierarchy where the system will be mounted, and options indicate whether the file system should be mounted "read only."
The kernel has a mount table with entries for every mounted file system. Each mount table contains:


The kernel only allows processes owned by a superuser to mount or unmount file systems. The kernel finds the inode of the special file that represents the file system to be mounted, extracts, the major and minor numbers that identify the appropriate disk section, and finds the inode of the directory on which the file system will be mounted. (Bach 121)
Having marked the mount table entry in use, the kernel prevents two mounts from using the same entry. By noting the device number of the attempted mount, the kernel can prevent other processes from mounting the same file system again. (Bach 122)
The kernel initializes fields int he file system super block, clearing the lock fields for the free block list and free inode list and setting the number of free inodes in the super block to 0. If the user mounts the file system read-only to disallow all write operations to the file system, the kernel sets a flag in the super block. Finally, the kernel marks the mounted-on inode as a mount point, so other processes later can identify it.

Unmounting a File System

To unmount a file system type:

unmount (special filename)

Special filename refers to the file system to be unmounted. When a file system is unmounted, the kernel accesses the inode of the device to be unmounted, retrieves the device number for the special file, releases the inode, and finds the mount table entry whose device number equals that of the special file. Before the kernel unmounts a file system, it makes sure that no files on the file system are still in use by searching the inode table for all files whose device number equals that of the file system being unmounted. (Bach 126) If any files from the file system are active, the unmount call fails.

Previous Contents Next