0% found this document useful (0 votes)
28 views

Operating Systems

Short explanation on Disk Fragmentation, File Systems and space allocation
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Operating Systems

Short explanation on Disk Fragmentation, File Systems and space allocation
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

OPERATING

SYSTEM
Disk Fragmentation, Storage Allocations,
File Systems
22/06/2024
EXTERNAL AND INTERNAL DISK
FRAGMENTATION
External Fragmentation

• What it is:

External fragmentation refers to wasted space between allocated


memory blocks. This happens when free memory becomes scattered
into small chunks throughout the storage device due to repeated
allocation and deallocation of data. These scattered free spaces are too
small to be used for storing larger data blocks.

• Cause:

External fragmentation is a result of dynamic memory allocation, where


space is assigned as needed. When files are deleted, they leave behind
free blocks. However, these free blocks might not be contiguous, creating
fragmented free space. Subsequent storage requests can't utilize these
scattered fragments, leading to external fragmentation.

• Analogy:
Imagine a collection of boxes in a storage room. As you take boxes out,
empty spaces appear, but they might be scattered around the room and
too small to fit new boxes of a certain size. External Fragmentation:

Internal Fragmentation:

• What it is:
Internal fragmentation refers to wasted space within a single allocated
memory block. This happens when the allocated block is larger than the
actual size of the data it needs to hold. The leftover space within the
block is unusable for other purposes.

• Cause:
Internal fragmentation is a consequence of using fixed-size memory
allocation. When a program or file needs memory, it's assigned the
smallest available block that can fit it entirely. This often results in some
unused space at the end of the block.

• Analogy:
Imagine a drawer where you store socks. You might have a large drawer
allocated for socks, but if you only have 5 pairs, there's wasted space in
the drawer that can't be used for other things.

2
3
Indexed Allocation

Indexed allocation is a versatile approach for file systems that prioritize

efficient storage utilization, fast random access, and scalability for large
files. However, for scenarios dealing primarily with very small files or
requiring the absolute fastest write performance, other allocation
methods like contiguous allocation might be preferable.

Advantages

• Reduced Fragmentation:

4
Unlike contiguous allocation, indexed allocation eliminates external
fragmentation. Since file data is stored in non-contiguous blocks on the
disk, gaps between files don't hinder future storage allocation. This
leads to more efficient utilization of disk space. No wasted space (like
leaving empty folders in the cabinet)

• Fast Random Access:

Indexed allocation excels at random access. Each file has an index block
that stores pointers to all the data blocks belonging to that file. This
allows the operating system to quickly locate any specific portion of the
file by simply referencing the index and the corresponding data block
address. Easy to jump to any part of a file (like quickly finding a specific
document)

• Scalability for Large Files:

Indexed allocation is well-suited for storing large files. The index block
can accommodate pointers to a vast number of data blocks, enabling
efficient management of large datasets. Can hold really big files (like
storing a whole bunch of papers)

Drawbacks of Indexed Allocation:

• Overhead: Maintaining an index block for each file introduces some


storage overhead. This can be a minor concern for large files, but for
very small files, the index block size might outweigh the actual data
stored. Takes a little extra space for the index card

Slower Write Operations: Updating files, especially growing files, can be


slightly slower with indexed allocation. Modifying the file content may

5
require updating the index block with new data block pointers, adding
an extra step compared to contiguous allocation. Might be slightly
slower for tiny files (like a single sheet of paper)

• Complexity: Managing the index data adds some complexity to the file
system compared to simpler allocation methods. A bit trickier to update
files (like adding or removing papers requires changing the index card)

Overall, indexed allocation is a good way to organize your computer


files, especially for larger ones you need to access quickly from different
parts.

Contiguous allocation

Imagine a bookshelf where each book needs its own whole shelf. That's
contiguous allocation.

Contiguous allocation is a straightforward method for allocating


memory to processes or files on a disk. Here's a breakdown of its key
features:

Advantages:

• Simple Implementation:

Contiguous allocation is easy to understand and implement for the


operating system. It requires minimal overhead for managing allocation
information.

6
• Fast Access:

Since data is stored in contiguous blocks, accessing any part of the file or
program involves minimal head movement for the disk drive's
read/write head, leading to faster data retrieval. This is beneficial for
applications that require frequent random access to data. Easy to find
your book (fast access)

• No External Fragmentation:

As long as there's a single contiguous block of free space large enough to


hold the entire file or program, external fragmentation is eliminated.
This simplifies storage management and avoids performance issues
caused by scattered free space. No wasted space between books (no
external fragmentation)

Disadvantages:

• Internal Fragmentation:

Contiguous allocation can suffer from internal fragmentation. This


occurs when a process or file size doesn't perfectly fit into the allocated
block, leaving wasted space within that block. While not as detrimental
as external fragmentation, it can lead to some inefficiency in disk space
utilization. Some shelves might have empty space at the end (internal
fragmentation)

• Limited Scalability:

7
Contiguous allocation can be challenging for large files or dynamic
memory allocation scenarios where process sizes can vary significantly.
Finding a single contiguous block large enough for a growing file can
become difficult as the disk fills up with other files. Hard to fit in new
books if shelves are full (limited scalability)

• Memory Allocation Wait Time:

In a system with many processes competing for memory, a process


might need to wait until a sufficiently large contiguous block becomes
available, potentially leading to delays in process execution.

Contiguous allocation is a good choice for:

• Simple systems with predictable memory requirements.

• Simple systems with predictable memory requirements.

• Applications that prioritize fast random access and minimal overhead.

• Scenarios where files are mostly static in size.

However, for systems with dynamic memory allocation needs, large file
sizes, or a significant number of processes competing for memory,
contiguous allocation might not be the most efficient approach. Other
allocation methods like indexed allocation or paging might be better
suited for such scenarios.

Linked allocation

8
Linked allocation is a valuable approach for file systems that prioritize
efficient space utilization, scalability for growing files, and a relatively
simple implementation. However, for scenarios where random access
performance is critical or dealing with primarily very small files, other
allocation methods like indexed allocation might be more suitable.

Use linked allocation when:

• Saving space is important (Lots of files being created and deleted)

• Files might get bigger later (Unpredictable file sizes)

• Keeping it simple is good (Easier to understand than other methods)

Strengths of Linked Allocation:


• Efficient Space Management:

Unlike contiguous allocation, linked allocation eliminates external


fragmentation. Since files are stored in non-contiguous blocks on the
disk, gaps between files don't hinder future storage allocation. This
leads to optimal utilization of available space, particularly in scenarios
with frequent file creation and deletion.

• Scalability for Growing Files:

Linked allocation is well-suited for storing files that might grow in size
over time. New data blocks can be easily appended to the existing file
chain, accommodating the expanding file size without needing to
relocate the entire file.

9
• Simplicity of Implementation:

Compared to indexed allocation, linked allocation has a simpler


conceptual design. Each data block contains a pointer to the next block
in the file chain, making it easier to understand and manage.

Drawbacks of Linked Allocation:


• Slower Random Access:

Random access to specific locations within a file can be slower with


linked allocation. The system needs to traverse the linked chain from the
beginning to reach the desired block, unlike indexed allocation where
the block address can be directly retrieved from the index.

• Overhead for Pointers:

Each data block in a linked allocation scheme requires additional space


to store the pointer to the next block. This overhead can be a minor
concern for large files, but for very small files, the pointer size might be
significant compared to the actual data stored.

• Potential for Data Corruption:

The integrity of the linked chain is crucial for accessing file data. it a
pointer becomes corrupted or accidentally overwritten, it can break the
chain and render the file inaccessible. Recovery might require additional
effort using file system utilities.

FAT file system

The FAT file system is a common format for data storage, known for:

10
• Simplicity & Compatibility: Easy to implement and works across
various devices and OSes.

• Small File Efficiency: Handles many small files well with minimal
overhead.

• Legacy Support: Still readable by most modern systems.

However, FAT has limitations:


• File Size Limits:

Traditional FAT versions restrict file sizes (2GB for FAT16).

• Scalability:

Not ideal for very large drives due to growing FAT table size.

• Security:

Offers minimal built-in security features.

Use FAT for removable media, legacy systems, or situations with mainly
small files. For larger files, advanced security, or bigger storage volumes,
consider NTFS, ext4, or exFAT.

FAT remains a popular choice for:


• Removable Media:

Due to its simplicity and compatibility, FAT is commonly used for


storage on removable media like USB flash drives and SD cards.

• Legacy Systems:

11
FAT is still supported by many older systems and devices, ensuring data
accessibility across different platforms.

• Limited Storage Needs:

When dealing with primarily small files and limited storage volumes,
FAT can be a sufficient and efficient option.

NTFS file system

• Journaling:

NTFS keeps track of file system changes in a journal, allowing for faster
recovery from errors or unexpected shutdowns. It's like having a backup
log of what you did in your filing cabinet, making it easier to undo
mistakes or restore lost files.

• Error Correction:

NTFS employs error correction mechanisms to detect and rectify


inconsistencies within the file system. This helps maintain data integrity
and prevents corruption.

• Reliability and Fault Tolerance:

NTFS prioritizes data integrity and system stability. It utilizes features


like journaling to track file system modifications and recover data in
case of unexpected system crashes or power outages. This acts like a
built-in backup system, safeguarding your valuable information from
accidental data loss.

• Large File Support:

12
NTFS excels at handling large files efficiently. Unlike FAT, which has
limitations on file size, NTFS can accommodate massive files commonly
used for multimedia content, databases. NTFS can handle much larger
files compared to FAT, making it suitable for storing big videos,
databases, or other voluminous data. Your filing cabinet can now
accommodate even giant folders.

• Disk Optimization:

Optimizes disk usage and minimizes fragmentation for faster data


access. NTFS optimizes disk usage by clustering data into smaller units,
improving read/write performance, especially for frequently accessed
files. This is like organizing your filing cabinet for faster retrieval.

• Scalability and Features:

Designed to grow with storage technology and offers features like


compression and disk quotas.

• Security and encryption:

Enhanced security to choose who has access to certain information. Ex:-


Folders, Accounts. Uses passwords and encryption methods.

Additional Features:
• Long Filenames:

NTFS supports much longer and more descriptive filenames compared


to FAT, allowing for better organization and clarity. You can now give
your files clear and meaningful labels instead of short, cryptic ones.

13
• Disk Quotas:

NTFS allows administrators to set storage limits for users or groups,


preventing them from exceeding allocated disk space. This is like setting
quotas for how much each person can store in the filing cabinet.

When to Use NTFS:


NTFS is the default file system for modern Windows operating systems
due to its comprehensive feature set. It's particularly well-suited for:

• Internal hard drives:

Where security, reliability, and performance are crucial.

• Large partitions:

NTFS can efficiently manage vast amounts of data storage.

• Multi-user environments:

Access control features ensure data security for multiple users.

Overall, NTFS is a secure, reliable, and efficient file system for modern
computing needs.

14

You might also like