Making and Mounting a File System
Explore how to create a file system using tools like mkfs and mount it to an existing directory, enabling access to multiple file systems within a unified structure. Understand the importance of mounting points and the risks involved in file operations, such as the TOCTTOU vulnerability, to manage persistent storage effectively.
We'll cover the following...
We’ve now toured the basic interfaces to access files, directories, and certain types of special types of links. But there is one more topic we should discuss: how to assemble a full directory tree from many underlying file systems. This task is accomplished via first making file systems, and then mounting them to make their contents accessible.
Making a file system
To make a file system, most file systems provide a tool, usually referred to as mkfs (pronounced “make fs”), that performs exactly this task. The idea is as follows: give the tool, as input, a device (such as a disk partition, e.g., /dev/sda1) and a file system type (e.g., ext3), and it simply writes an empty file system, starting with a root directory, onto that disk partition.
And mkfs said, let there be a file system!
Mounting a file system
However, once such a file system is created, it needs to be made accessible within the uniform file-system tree. This task is achieved via the mount program (which makes the underlying system call mount() to do the real work). What mount does, quite simply is take an existing directory as a target mount point and essentially paste a ...