What are the contiguous, linked and indexed file allocation methods?
MediumConceptFile Systems & Disk Scheduling
Answer
File allocation methods decide how a file's data blocks are placed on disk and how the file system finds them again.
- Contiguous: the file occupies consecutive blocks, and the directory stores the start block and length. Sequential and random access are fast (block i is at start + i), but it causes external fragmentation and files are hard to grow.
- Linked: each block holds a pointer to the next, and the directory stores the first block. There is no external fragmentation and files grow easily, but random access must follow the chain, and one damaged pointer loses the rest of the file. FAT (File Allocation Table), used on many USB drives, keeps these pointers together in one table.
- Indexed: an index block lists all of the file's block numbers, giving fast random access without external fragmentation, at the cost of an extra block per file. Unix inodes use a multi-level indexed scheme.
Example: a three-block file.
Contiguous: blocks 10, 11, 12; the directory stores (start 10, length 3).
Linked: blocks 9 → 16 → 1 → end; the directory stores start 9.
Indexed: index block 19 contains [9, 16, 1]. To read the third block, indexed allocation reads entry 3 of block 19 and goes straight to block 1, while linked allocation must first read blocks 9 and 16 to follow the pointers.
More in File Systems & Disk Scheduling
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | What is an inode, and what information does it store? | Concept | Medium | Read the answer to What is an inode, and what information does it store? | |||
| 2 | How do directories map file names to inodes, and what is the difference between a hard link and a soft link? | Concept | Medium | Read the answer to How do directories map file names to inodes, and what is the difference between a hard link and a soft link? | |||
| 3 | What are the contiguous, linked and indexed file allocation methods? | Concept | Medium | Read the answer to What are the contiguous, linked and indexed file allocation methods? | |||
| 4 | Compare FCFS, SSTF, SCAN and C-SCAN disk scheduling. | Concept | Hard | Read the answer to Compare FCFS, SSTF, SCAN and C-SCAN disk scheduling. |