---
title: "File and attributes; allocation methods"
subject: "Operating System"
chapter: 5
key: "semester_6/operating_system:file-attributes-allocation-methods"
source: https://www.bctengineer.com/q/semester_6/operating_system/file-attributes-allocation-methods
site: BCT Engineering
---

# File and attributes; allocation methods

Operating System · Chapter 5: File Systems

- Asked in: 2071 Magh, 3+7 marks
- Video: [Allocation Methods | File Allocation Methods | Contiguous | linked | indexed | chain | os | files](https://www.youtube.com/watch?v=gK6L3v1b8AM) — Sudhakar Atchala
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/file-attributes-allocation-methods
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-5

## Question

What is file and their attributes? Briefly explain the file allocation methods.

## Short answer

File attributes: name, ID, type, location, size, permissions, timestamps. Allocation methods: contiguous (fast, external fragmentation), linked list (no fragmentation, slow random), FAT (pointers in memory table), indexed/i-node (fast random, indirect blocks).

## Answer

#### File and its attributes
A **file** is a named collection of related information stored on secondary storage; it is the logical unit of storage seen by the user (programs, documents, data). Files have an internal structure (byte stream, records, tree) and a type (regular, directory, special).

**File attributes** (metadata) maintained for each file:
| Attribute | Meaning |
|---|---|
| Name | Human-readable identifier |
| Identifier | Unique tag (i-node number) used by the system |
| Type | Text, executable, directory, etc. |
| Location | Pointer to the device and disk blocks |
| Size | Current size in bytes/blocks |
| Protection | Permissions: read, write, execute for owner, group, others |
| Time, date, user ID | Creation, last access and modification, owner |
| Flags | Read-only, hidden, system, archive, lock flags |

#### File allocation methods
The file allocation method decides which disk blocks belong to a file. The main methods are:

**1. Contiguous allocation** - each file occupies a set of consecutive blocks. The directory stores the start block and length.
```text
 file A: blocks 0-3   file B: blocks 4-6   free 7-...
 [A][A][A][A][B][B][B][ ][ ]
```
- Advantages: simple; very fast sequential and direct access (only one seek); only start and length are stored.
- Disadvantages: external fragmentation (needs compaction); file size must be known in advance; file growth is difficult.

**2. Linked-list allocation** - each block contains a pointer to the next block; the directory stores the first block.
```text
 [blk 9 |->2] [blk 2 |->14] [blk 14 |->nil]
```
- Advantages: no external fragmentation; files can grow easily; no need to know size.
- Disadvantages: random access is very slow (must follow the chain); the pointer takes space in each block (so the data size is no longer a power of 2); one lost pointer breaks the file (poor reliability).

**3. Linked list with a table in memory (FAT)** - the pointers are moved out of the data blocks into a File Allocation Table in memory; entry *i* gives the block after block *i*.
- Advantages: full block available for data; random access is faster (chain followed in memory).
- Disadvantages: the whole table must be in memory (a 1 TB disk with 1 KB blocks needs 10⁹ entries), so it does not scale.

**4. Indexed allocation (i-node)** - each file has an index block (i-node) that lists the addresses of all its blocks (UNIX adds indirect blocks for large files).
```text
 i-node: [b1][b2][b3]...[single indirect]-->[b..][b..]
```
- Advantages: supports direct access, no external fragmentation, only the i-nodes of open files need to be in memory.
- Disadvantages: index block overhead (even for a small file); very large files need multiple levels of indirection.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the file identifier attribute?
   A. A human-readable name
   B. A unique tag such as the i-node number used by the system
   C. The file size
   D. Permissions
   Answer: B. Name is for humans; identifier is for the system. (Key point: Identifier)

2. What does the directory store for contiguous allocation?
   A. Start block and length
   B. Every block address
   C. Only first block
   D. Next pointers
   Answer: A. Only start and length are needed. (Key point: Contiguous directory)

3. How does FAT improve on plain linked allocation?
   A. Pointers moved to an in-memory table, giving a full block for data and faster random access
   B. Removes need for any table
   C. Uses contiguous blocks
   D. Removes pointers entirely
   Answer: A. The chain is followed in memory and blocks hold only data. (Key point: FAT advantage)

## Related in Operating System

- [File attributes; levels of directories](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-attributes-directory-levels) — Operating System, chapter 5
- [File allocation methods; free space management](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-allocation-free-space-methods) — Operating System, chapter 5, asked 2×
- [File system vs virtual memory; contiguous allocation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-vs-virtual-memory-contiguous-tape) — Operating System, chapter 5
- [File allocation and access methods](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-allocation-access-methods) — Operating System, chapter 5
- [File attributes; directory systems; free blocks](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-attribute-directory-free-blocks) — Operating System, chapter 5
- [File attributes; FS implementation ways](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-attribute-implementation-best) — Operating System, chapter 5
