Introduction
File allocation strategies in operating systems are methods used to allocate space for files on storage devices such as hard disks. These strategies play a crucial role in managing storage efficiently and optimizing file access. Here's an overview of some common file allocation strategies:

Some Terms :
- Seek Time : Seek time is the time it takes for the read/write head of a disk drive to move to the track where the data to be read or written is located.
- Disk Head : The disk head is the component of a disk drive that reads and writes data to the disk platter. It is mounted on an arm that moves it across the disk surface.
- Internal Fragmentation : Occurs when allocated memory may have some unused space due to the fixed size of memory allocation units.
- External Fragmentation: Happens when free memory is scattered in small blocks across the storage, making it difficult to allocate contiguous blocks of memory.
- Random Access: Allows data to be read or written in any order, making it very fast. Used for primary storage where speed is crucial.
- Direct Access: Refers to the ability to access data directly without sequentially searching through other data.
- File Control Block (FCB): A File Control Block is a data structure used by file systems to store information about a file.
- File Allocation Table (FAT): The File Allocation Table is a legacy file system architecture used in various operating systems, including MS-DOS and Windows.
Contiguous File Allocation:
- Purpose: Simplifies file access and management. Ideal for files that are accessed sequentially.
- Seek Time: Typically very low for sequential access since data blocks are stored consecutively.
Advantages:
- It is very easy to implement.
- There is a minimum amount of seek time.
- The disk head movement is minimum.
- Memory access is faster.
Disadvantages:
- At the time of creation, the file size must be initialized.
- As it is pre-initialized, the size cannot increase.
- Due to its constrained allocation, it is possible that the disk would fragment internally or externally.
Applications:
- Suitable for systems where file sizes are known in advance and do not change often, such as read-only media (e.g., CD-ROMs, DVD-ROMs).
- Effective in real-time systems where fast access time is critical.
Indexed File Allocation:
- Purpose: Combines benefits of contiguous and linked allocation by using an index block to manage pointers.
- Seek Time: Moderate seek times as initial seek is needed to access the index block, followed by seeks to individual data blocks.
Advantages:
- It reduces the possibilities of external fragmentation.
- Rather than accessing sequentially it has direct access to the block.
Disadvantages:
- Here more pointer overhead is there.
- If we lose the index block we cannot access the complete file.
- It is possible that a single index block cannot keep all the pointers for some large files.
Applications:
- Suitable for systems requiring efficient random access to file blocks, such as database systems.
- Ideal for file systems where file sizes vary greatly and frequent updates occur.
Linked File Allocation:
- Purpose: Allows files to grow dynamically without requiring contiguous disk space. Suitable for systems where file sizes vary and are modified frequently.
- Seek Time: Higher seek times for both sequential and random access due to the need to follow pointers from one block to the next.
Advantages:
- There is no external fragmentation.
- The directory entry just needs the address of starting block.
- The memory is not needed in contiguous form, it is more flexible than contiguous file allocation.
Disadvantages:
- It does not support random access or direct access.
- If pointers are affected so the disk blocks are also affected.
- Extra space is required for pointers in the block.
Applications:
- Suitable for file systems with high flexibility requirements and where file sizes change frequently, such as general-purpose operating systems.
- Useful in systems where sequential access is more common than random access.
Contiguous file allocation is a straightforward method where files are allocated consecutive blocks of disk space. It's one of the simplest techniques used in file systems. Here's how it works:

The indexed file allocation is somewhat similar to linked file allocation as indexed file allocation also uses pointers but the difference is here all the pointers are put together into one location which is called index block. That means we will get all the locations of blocks in one index file. The blocks and pointers were spread over the memory in the Linked Allocation method, where retrieval was accomplished by visiting each block sequentially. But here in indexed allocation, it becomes easier with the index block to retrieve.

The Linked file allocation overcomes the drawback of contiguous file allocation. Here the file which we store on the hard disk is stored in a scattered manner according to the space available on the hard disk. Now, you must be thinking about how the OS remembers that all the scattered blocks belong to the same file. So as the name linked File Allocation suggests, the pointers are used to point to the next block of the same file, therefore along with the entry of each file each block also stores the pointer to the next block.
