Operating System: Module – 1
Module – 5
File System File concept
File Systems in Operating System
A file system is a method an operating system uses to store, organize, and manage files
and directories on a storage device. Some common types of file systems include:
• FAT (File Allocation Table): An older file system used by older versions of
Windows and other operating systems.
• NTFS (New Technology File System): A modern file system used by Windows. It
supports features such as file and folder permissions, compression, and
encryption.
• ext (Extended File System): A file system commonly used on Linux and Unix-based
operating systems.
• HFS (Hierarchical File System): A file system used by macOS.
• APFS (Apple File System): A new file system introduced by Apple for their Macs
and iOS devices.
A file is a collection of related information that is recorded on secondary storage. Or file
is a collection of logically related entities. From the user’s perspective, a file is the
smallest allotment of logical secondary storage.
The name of the file is divided into two parts as shown below:
• Name
• Extension, separated by a period.
Issues Handled By File System
We’ve seen a variety of data structures where the file could be kept. The file system’s job
is to keep the files organized in the best way possible.
A free space is created on the hard drive whenever a file is deleted from it. To reallocate
them to other files, many of these spaces may need to be recovered. Choosing where to
store the files on the hard disc is the main issue with files one block may or may not be
used to store a file. It may be kept in the disk’s non-contiguous blocks. We must keep
track of all the blocks where the files are partially located.
Page 1|7
Operating System: Module – 1
File Directories
The collection of files is a file directory. The directory contains information about
the files, including attributes, location, and ownership. Much of this information,
especially that is concerned with storage, is managed by the operating system. The
directory is itself a file, accessible by various file management routines.
Below is information contained in a device directory.
• Name
• Type
• Address
• Current length
• Maximum length
• Date last accessed
• Date last updated
• Owner id
• Protection information
The operation performed on the directory are:
• Search for a file
• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system
Advantages of Maintaining Directories
• Efficiency: A file can be located more quickly.
• Naming: It becomes convenient for users as two users can have same name for
different files or may have different name for same file.
• Grouping: Logical grouping of files can be done by properties e.g. all java programs,
all games etc.
Page 2|7
Operating System: Module – 1
Single-Level Directory
In this, a single directory is maintained for all the users.
• Naming Problem: Users cannot have the same name for two files.
• Grouping Problem: Users cannot group files according to their needs
Two-Level Directory
In this separate directory for each user is maintained.
• Path Name: Due to two levels, there is a path name for every file to locate that
file.
• Now, we can have the same file name for different users.
• Searching is efficient in this method.
Free Space Management Techniques
• Linked Allocation: In this technique, each file is represented by a linked list of
disk blocks. When a file is created, the operating system finds enough free space
on the disk and links the blocks of the file to form a chain. This method is simple to
implement but can lead to fragmentation and waste of space.
• Contiguous Allocation: In this technique, each file is stored as a contiguous block
of disk space. When a file is created, the operating system finds a contiguous block
of free space and assigns it to the file. This method is efficient as it minimizes
Page 3|7
Operating System: Module – 1
fragmentation but suffers from the problem of external fragmentation.
• Indexed Allocation: In this technique, a separate index block is used to store the
addresses of all the disk blocks that make up a file. When a file is created, the
operating system creates an index block and stores the addresses of all the blocks
in the file. This method is efficient in terms of storage space and minimizes
fragmentation.
• File Allocation Table (FAT): In this technique, the operating system uses a file
allocation table to keep track of the location of each file on the disk. When a file is
created, the operating system updates the file allocation table with the address of
the disk blocks that make up the file. This method is widely used in Microsoft
Windows operating systems.
• Volume Shadow Copy: This is a technology used in Microsoft Windows operating
systems to create backup copies of files or entire volumes. When a file is modified,
the operating system creates a shadow copy of the file and stores it in a separate
location. This method is useful for data recovery and protection against accidental
file deletion.
Free Space Management Techniques
• Linked Allocation: In this technique, each file is represented by a linked list of
disk blocks. When a file is created, the operating system finds enough free space
on the disk and links the blocks of the file to form a chain. This method is simple to
implement but can lead to fragmentation and waste of space.
• Contiguous Allocation: In this technique, each file is stored as a contiguous block
of disk space. When a file is created, the operating system finds a contiguous block
of free space and assigns it to the file. This method is efficient as it minimizes
fragmentation but suffers from the problem of external fragmentation.
• Indexed Allocation: In this technique, a separate index block is used to store the
addresses of all the disk blocks that make up a file. When a file is created, the
operating system creates an index block and stores the addresses of all the blocks
in the file. This method is efficient in terms of storage space and minimizes
fragmentation.
Page 4|7
Operating System: Module – 1
• File Allocation Table (FAT): In this technique, the operating system uses a file
allocation table to keep track of the location of each file on the disk. When a file is
created, the operating system updates the file allocation table with the address of
the disk blocks that make up the file. This method is widely used in Microsoft
Windows operating systems.
• Volume Shadow Copy: This is a technology used in Microsoft Windows operating
systems to create backup copies of files or entire volumes. When a file is modified,
the operating system creates a shadow copy of the file and stores it in a separate
location. This method is useful for data recovery and protection against accidental
file deletion.
Advantages:
• Simple to understand.
• Finding the first free block is efficient. It requires scanning the words (a group of
8 bits) in a bitmap for a non-zero word. (A 0-valued word has all bits 0). The first
free block is then found by scanning for the first 1 bit in the non-zero word.
Disadvantages:
• For finding a free block, Operating System needs to iterate all the blocks which is
time consuming.
• The efficiency of this method reduces as the disk size increases.
2. Linked List
In this approach, the free disk blocks are linked together i.e. a free block contains
a pointer to the next free block. The block number of the very first disk block is
stored at a separate location on disk and is also cached in memory.
Page 5|7
Operating System: Module – 1
Advantages:
• The total available space is used efficiently using this method.
• Dynamic allocation in Linked List is easy, thus can add the space as per the
requirement dynamically.
Disadvantages:
• When the size of Linked List increases, the headache of miniating pointers is also
increases.
• This method is not efficient during iteration of each block of memory.
Grouping
This approach stores the address of the free blocks in the first free block. The first
free block stores the address of some, say n free blocks. Out of these n blocks, the
first n-1 blocks are actually free and the last block contains the address of next
free n blocks. An advantage of this approach is that the addresses of a group of
free disk blocks can be found easily.
Advantage:
• Finding free blocks in massive amount can be done easily using this method.
Disadvantage:
• The only disadvantage is, we need to alter the entire list, if any of the block of the
list is occupied.
Counting
This approach stores the address of the first free disk block and a number n of free
contiguous disk blocks that follow the first block. Every entry in the list would
contain:
Page 6|7
Operating System: Module – 1
• Address of first free disk block.
• A number n.
Advantages:
• Using this method, a group of entire free blocks can take place easily and Fastly.
• The list formed in this method is especially smaller in size.
Disadvantage:
• The first free block in this method, keeps account of other free blocks. Thus, due
to that one block the space requirement is more.
Page 7|7