File system management is the process of organizing, managing, and maintaining files and directories on a storage device. It includes creating, modifying, and maintaining the file system on a disk, creating and deleting files and directories, and managing the allocation of disk space.

The most basic function of file system management is creating and deleting files and directories. When you create a new file, the file system assigns it a unique name and location on the disk, and when you delete a file, the file system removes it from the disk.

File system management also includes managing the permissions and access controls for files and directories, which determines who can read, write, or execute a file. This is important for maintaining data security and preventing unauthorized access to sensitive information.

Importance of File System Management:

File system management is an essential aspect of computer science and information technology, as it plays a critical role in the overall performance, stability, and security of a computer system. Some of the most important reasons why file system management is important to include:

  1. Data organization: A well-organized file system can help to improve the performance of a computer by reducing the amount of disk I/O required to access files. It also makes it easier for users to find and access the files they need.
  2. Disk space management: File system management is responsible for managing the allocation of disk space. When a file is created, the file system must find an available space on the disk to store it. It also needs to manage the space occupied by deleted files to make it available for new files.
  3. Data security: File system management includes managing the permissions and access controls for files and directories, which determines who can read, write, or execute a file. This is important for maintaining data security and preventing unauthorized access to sensitive information.
  4. Backup and recovery: File system management also includes managing the file metadata, which is data about the file, such as its creation date, modification date, and file size. This information can be used to manage backups and to track changes to the file over time.
  5. File System Consistency: File system management ensures that the file system is in a consistent state by making sure that the file system’s data structures are not corrupted, and that there are no inconsistencies in the file system.
  6. Data Integrity: File system management ensures that the data stored in the file system is not corrupted and that it is accessible even in the event of a power failure or other system failure.

Overall, file system management plays a crucial role in the overall performance and stability of a computer system.

What is File System?

A file system in OS dictates how the contents of a storage medium are stored and organized. These storage media (such as secondary memory, external drives, etc) could be computer secondary memory, flash memory, etc. The contents are either files or directories. Most of the time, a storage device has a number of partitions. Each of these partitions is formatted with an empty filesystem for that device. A filesystem helps in separating the data on the storage into comparatively smaller and simpler segments. These chunks are files and directories. The filesystem also provides for storing data related to files, such as their name, extension, permissions, etc.

Properties of a Filesystem

  • Files are stored on a storage medium such as disk and do not vanish when a user logs out of the computer system.
  • With each file are associated access permissions, which permit controlled sharing of that file.
  • Files may form arranged or complex structures according to the relationship among them.
  • Several files can be grouped together under a directory.
  • A directory also referred to as a folder also has attributes similar to those of a file, such as a name, size, location, access permissions, etc.
  • A file system also provides several features such as a crash recovery mechanism, data loss/corruption prevention, etc.

File Structure in OS

A file is a logical unit of information. They are produced by processes. The operating system manages files. While creating a file, a name is assigned to it. After this process has terminated, the file exists and remains accessible to other processes. The name of a file has two parts, separated by a dot. Example, code.cpp is a c++ program file with name code and extension cpp. The name of the file before the dot is a label for the file’s identification, while the part after the dot is called the file extension which indicates the type of the file.

What are File Attributes in OS?

File attributes are configuration and information related to files. These attributes grant/deny requests of a user/process for access, modifying, relocating, or deleting it. Some common examples of file attributes are:

  • Read-only: Allows a file to be only read.
  • Read-Write: Allows a file to be read and written to.
  • Hidden: File is made invisible during non-privileged regular operations.
  • Execute: Allows a file to be executed like a program. Other than these there are several attributes. Many of them are platform-specific.

File Access Mechanisms in OS

Following are the 3 types of file-accessing mechanisms in an operating system:

1. Direct

This method represents a file’s disk model. Just like a disk, direct access mechanism allows random access to any file block. A file is divided into a number of blocks. These blocks are of the same size. The file is viewed as an ordered sequence of these blocks. Thus the OS can do a read-write operation upon any random block. Following are the three operations under direct mechanism:

  1. Read x: read contents of block x
  2. Write x: write to block x
  3. Goto x: jump to block x

2. Sequential Access

This is a simple way to access the information in a file. Contents of a file are accessed sequentially (one record after another). This method is used by editors and compilers. Tape drives use a sequential method, processing a memory block at a time. They were a form of the storage medium in computers used in earlier times. Following are the 3 operations in sequential access:

  1. Read next: read the next portion of the file.
  2. Write next: add a node to the end of the file and move the pointer to it.
  3. Reset: move the pointer to the starting of the file.

3. Indexed Access Method

This method is a variant of the direct access method. It maintains an index that contains the addresses of the file blocks. To access a record, the OS will first search its address in the index which will then point to the actual address of that block of the file that has the required record.

File Types:

There are a large number of file types. Each has a particular purpose. The type of a file indicates its use cases, contents, etc. Some common types are:

  • Media: Media files store media data such as images, audio, icons, video, etc. Common extensions: img, mp3, mp4, jpg, png, flac, etc.
  • Programs: These files store code, markup, commands, scripts, and are usually executable. Common extensions: c, cpp, java, xml, html, css, js, ts, py, sql, etc.
  • Operating System Level: These files are present with the OS for its internal use. Common extensions: bin, sh, bat, dl, etc.
  • Document: These files are used for managing office programs such as documents, spreadsheets, etc.
  • Common extensions: xl, doc, docx, pdf, ppt, etc.
  • Miscellaneous: Generic text file(.txt), canvas files, proprietary files, etc.

File Types in an OS

There are numerous file types that an operating system uses internally and are not generally used or required by the system user. These files could be application software files, kernel files, configuration files, metadata files, etc. Windows supports the following two file types:

1. Regular Files

Regular files consist of information related to the user. The files are usually either ASCII or binary. ASCII files contain lines of text. The major benefit of an ASCII file is that it can be displayed or printed as it is, and it can be edited using a text editor.

Binary files on printing may give some random junk content. Usually, a binary file would have some sort of internal structure that is only known to the program that uses it. A binary file is a sequence of bytes, which if is in the proper format, can be executed by the operating system. Regular files are supported by both Windows as well as UNIX-based operating systems.

2. Directories

A directory in the filesystem is a structure that contains references to other files and possibly other directories. Files could be arranged by storing related files in the same directory. Directories are supported by both Windows as well as UNIX-based operating systems.

3. Character Special Files

A character special file provides access to an I/O device. Examples of character special files include a terminal file, a system console file, a NULL file, a file descriptor file, etc.

Each character special file has a device major number and a device minor number. The device major number associated with a character special file identifies the device type. The device minor number associated with a character special file identifies a specific device of a given device type. Character special files are supported by UNIX-based operating systems.

4. Block Special Files

Block special files enable buffered access to hardware devices They also provide some abstraction from their specifics. Unlike character special files, block special files always allow the programmer to read and write a block of any size or alignment. Block special files are supported by UNIX-based operating systems.

Functions of a File

  • They are used for storing data in a computer.
  • They enable the separation of data according to some criteria.
  • They enable efficient, simple, organized access to data.
  • They help in isolating sensitive or important data from the rest of the data.
  • They enable locating particular data items in the storage medium.

Common Terms in Filesystem

Here are some common terms used in filesystems:

  • Directory: A container for files and other directories.
  • File: A collection of data stored on a storage device.
  • Path: The location of a file or directory in the filesystem.
  • Root directory: The top-level directory in a filesystem.
  • Subdirectory: A directory that is contained within another directory.
  • File hierarchy: The organization of files and directories in a hierarchical structure.
  • Partition: A part of the storage medium is virtually separate from the rest of the storage.
  • File permissions: Access controls that determine who can read, write, and execute files.
  • File Extension: A label appended to the name of a file after a dot. Gives information of the purpose of and information in the file.
  • Hard link: A directory entry that points to the same file as another entry.
  • Symbolic link: A file that contains a reference to another file or directory.
  • Mount point: The location in the filesystem where a storage device is mounted.
  • Formatting: The process of preparing a storage device for use by a filesystem.
  • Defragmenting: The process of organizing files on a storage device to improve performance.

Space allocation

Following are the three methods of space allocation in an operating system:

  1. Contiguous allocation: In this method, all the blocks of a file are stored together in a contiguous block of space on the storage device. This method is simple to implement and provides good performance, but it can lead to fragmentation over time.
  2. Linked allocation: In this method, each file is represented by a linked list of blocks. Each block in the list contains a pointer to the next block. This method is more complex to implement than contiguous allocation, but it is more efficient in terms of space usage.
  3. Indexed allocation: In this method, each file is represented by a table of block addresses that are indexed by the file’s name. This method is more efficient than the linked allocation in terms of space usage, but it is more complex to implement.
  4. Multi-level index allocation: This method is an extension of indexed allocation. This method uses multiple levels of tables to store the block addresses of a file, reducing the size of each table and making it more efficient for large files.
  5. Extent-based allocation: This method groups the blocks of a file together into extents, which are contiguous ranges of blocks. By allocating extents rather than individual blocks, this method can reduce fragmentation and improve performance.

What is a Directory?

A directory, also known as a folder, is a container that holds files and other directories. In a file system, directories are used to organize files and make it easier to find the files that you need. A directory can contain any number of files and other directories, and it can be nested within other directories to create a hierarchical organization of files.

Directories can be created, deleted, renamed, and moved just like files. They also can have permissions, ownership and timestamps like files.

Partitioning schemes, system firmware, and booting

When partitioning a storage device, we have two partitioning methods (or schemes ) to choose from:

  • Master Boot Record (MBR) is a scheme for partitioning a storage device, typically a hard drive, into multiple partitions. It is the standard partitioning scheme used on BIOS-based computers. The MBR scheme uses a small program called the Master Boot Code (MBC) which is located at the beginning of the storage device. This program is executed when the computer starts up and is responsible for loading the operating system. The MBR scheme also contains a table of partition information, which describes the size and location of each partition on the storage device.
  • GUID Partition Table (GPT) is a newer partitioning scheme that is an alternative to the MBR scheme. It is used on computers that use the UEFI firmware interface instead of the BIOS firmware. GPT is part of the UEFI specification and is designed to overcome some of the limitations of the MBR scheme. One of the main advantages of GPT is that it supports larger storage devices, up to 9.4 zettabytes, compared to the 2 terabytes limit of MBR. It also supports up to 128 partitions, compared to the four partitions limit of MBR. GPT also includes a protective MBR, which is used to detect and prevent boot sector viruses.

The architecture of a file system typically consists of three layers:

  1. The User Interface Layer: This is the topmost layer of the file system, which provides the interface through which users interact with the file system. This layer includes the commands and utilities used to create, delete, and manipulate files and directories.
  2. The File System Layer: This is the middle layer of the file system, which is responsible for managing the organization and storage of files and directories on the storage device. It includes the data structures and algorithms used to manage the file system’s metadata, such as file and directory names, timestamps, and permissions.
  3. The Device Layer: This is the bottom layer of the file system, which is responsible for interfacing with the physical storage device. It includes the driver software and firmware that communicates with the device’s hardware, such as the read and write operations.

File System types in Windows:

There are several file system types that can be used in Windows:

  1. NTFS (New Technology File System): This is the default file system type used in modern versions of Windows. NTFS is a robust, feature-rich file system that offers advanced features such as file-level security, encryption, and large file support.
  2. FAT32 (File Allocation Table 32-bit): This is an older file system type that was commonly used in earlier versions of Windows. FAT32 has a smaller file size limit and fewer features compared to NTFS, but it is compatible with a wider range of operating systems, making it useful for removable drives and other external storage devices.
  3. exFAT (Extended File Allocation Table): This file system was introduced by Microsoft as a replacement for FAT32, and it is designed to provide the compatibility of FAT32 with the large file size support of NTFS. exFAT is also compatible with a wide range of operating systems, and it is often used for removable drives and other external storage devices.

File System types in Linux

There are several file system types that can be used in Linux:

  1. ext4: This is the default file system type in most modern Linux distributions. Ext4 is a robust, feature-rich file system that offers advanced features such as journaling, extents, and large file support.
  2. ext3: This is an older file system type that was commonly used in earlier versions of Linux. Ext3 is similar to ext4, but it doesn’t support extents.
  3. XFS: This is a high-performance file system that is designed for large storage volumes and high-performance workloads. XFS is a popular choice for high-performance storage scenarios, such as databases and media streaming.
  4. Other file system types like ReiserFS, JFS, NTFS, and FAT32 are also supported in Linux, but they are not as common as the abovementioned.

File System types in UNIX:

here are several file system types that can be used in UNIX-like operating systems, including:

  1. UFS (UNIX File System): This is the default file system type used in many UNIX-like operating systems, such as BSD and Solaris. UFS is a robust, feature-rich file system that offers advanced features such as journaling and large file support.
  2. ZFS (Zettabyte File System): This is a newer file system type that is designed to provide advanced features such as copy-on-write, snap-shotting, and data integrity. ZFS is a popular choice for storage scenarios that require data resiliency and protection against data corruption.
  3. Other file system types like ext3, ext4, Btrfs, and ReiserFS are also supported in UNIX-like operating systems, but they are not as common as the above mentioned.

File System types in Embedded System:

There are several file system types that can be used in embedded systems, including:

  1. YAFFS (Yet Another Flash File System): This is a file system designed specifically for use on flash memory devices. YAFFS is designed to be efficient and reliable in embedded systems, and it supports wear leveling, bad block management, and journaling.
  2. JFFS (Journaling Flash File System): This is a file system designed specifically for use on flash memory devices. JFFS is designed to be efficient and reliable in embedded systems, and it supports wear leveling, bad block management, and journaling.
  3. UBIFS (Unsorted Block Image File System): This is a file system designed specifically for use on flash memory devices. UBIFS is designed to be efficient and reliable in embedded systems, and it supports wear leveling, bad block management, and journaling.
  4. ROMFS (ROM File System): This is a read-only file system that is commonly used in embedded systems that have limited storage capacity and don’t require frequent updates.

It’s important to note that different file system types have different features, performance characteristics, and compatibility with different types of embedded systems, so it’s important to choose the appropriate file system type based on the specific needs and requirements of the storage device and the embedded system being used.

Leave a Reply