File Systems Questions with Answers

31 practice questions on File Systems (Operating Systems) with answers and step-by-step solutions. Try 10 samples below, then practise all 31 free in the AptiNest app.

Sample questions

Question 1Easy

Which allocation method stores each file in a run of consecutive disk blocks?

  1. Linked allocation
  2. Contiguous allocation
  3. FAT chaining
  4. Indexed allocation

Answer: B. Contiguous allocation

Explanation

Contiguous allocation needs only a start block and length and supports fast direct access, but suffers from external fragmentation.

Step-by-step solution

  1. Contiguous allocation stores files in one continuous block on disk.
  2. This method uses a single starting block and file size to locate data.
  3. It allows quick access as the file is stored without gaps.
  4. External fragmentation occurs because free spaces are scattered.
  5. The correct answer is contiguous allocation.

Why the other options are wrong

  • A. Linked allocation chains blocks together with pointers, so the blocks are not stored consecutively.
  • C. FAT chaining uses a table of links between blocks, so the blocks do not need to be consecutive.
  • D. Indexed allocation keeps block addresses in an index block, so its blocks can be scattered across the disk.

Tip: Remember: Contiguous allocation = single block of storage for a file.

Question 2Easy

Which directory structure allows the same file or subdirectory to appear in several directories without copying?

  1. Acyclic-graph directory
  2. Two-level directory
  3. Single-level directory
  4. Tree with no sharing

Answer: A. Acyclic-graph directory

Explanation

Acyclic-graph directories allow sharing via links while forbidding cycles that would complicate traversal and deletion.

Step-by-step solution

  1. Acyclic-graph directory uses links to share files across directories without copying.
  2. Links let same file appear in multiple directories without duplication.
  3. This structure avoids cycles for easier navigation and management.
  4. Other structures like single-level or two-level do not support shared entries.
  5. Tree with no sharing lacks linking capability for shared files.
  6. Final answer: Acyclic-graph directory.

Why the other options are wrong

  • B. A two-level directory gives each user a directory, but it does not let one file appear in several places.
  • C. A single-level directory is one flat list of files, so the same file cannot be shared across directories.
  • D. A tree with no sharing gives each file one place only; appearing in several directories would need copies.

Tip: Use acyclic-graph for shared files without copying.

Question 3Easy

Which is the correct sequence of system calls to read a file in UNIX?

  1. create, read, delete
  2. open, close, read
  3. read, open, close
  4. open, read, close

Answer: D. open, read, close

Explanation

open() returns a file descriptor, read() uses it, and close() releases it.

Step-by-step solution

  1. open() is used to open the file and get a file descriptor.
  2. read() uses the file descriptor to read data from the file.
  3. close() is called to release the file descriptor and close the file.
  4. The correct order is open, read, close.
  5. Final answer: open, read, close.

Why the other options are wrong

  • A. create, read, delete does not read a file; the file must be opened first and then closed when done.
  • B. close before read is wrong, because the file must be opened before it can be read or closed.
  • C. read before open is invalid, because the file descriptor used by read comes from open.

Tip: Remember the sequence: open first, then read, then close.

Question 4Easy

Which file attribute tells the OS who may read, write or execute a file?

  1. Its permissions (access control)
  2. Its extension
  3. Its owner's home directory
  4. Its creation time

Answer: A. Its permissions (access control)

Explanation

Permissions or access-control lists are checked by the OS on every open.

Step-by-step solution

  1. File permissions control who can read, write or execute a file.
  2. Permissions are stored as part of the file's attributes in the OS.
  3. The OS checks these permissions before allowing access to the file.
  4. This is known as the file's access control or permission settings.
  5. Therefore, the correct attribute is its permissions (access control).

Why the other options are wrong

  • B. The extension only hints at the file type; it does not control who may access it.
  • C. The owner's home directory is a location, not the rule for read, write or execute access.
  • D. Creation time records when the file was made; it does not set who may access it.

Tip: Remember: Permissions = access control = who can use the file.

Question 5Medium

A file of 10,000 bytes is stored in 4 KB blocks. How many blocks does it use and how much space is wasted in its last block?

  1. 3 blocks, 1,808 bytes wasted
  2. 2 blocks, 1,808 bytes wasted
  3. 3 blocks, 2,288 bytes wasted
  4. 3 blocks, no space wasted

Answer: C. 3 blocks, 2,288 bytes wasted

Explanation

10,000 / 4,096 rounds up to 3 blocks = 12,288 bytes; 12,288 - 10,000 = 2,288 bytes of internal fragmentation.

Step-by-step solution

  1. 10,000 ÷ 4,096 = 2.44, so 3 blocks are needed.
  2. 3 blocks hold 3 × 4,096 = 12,288 bytes.
  3. Wasted space = 12,288 − 10,000 = 2,288 bytes. Marked answer: 3 blocks, 2,288 bytes wasted.

Why the other options are wrong

  • A. 1,808 is the number of bytes used in the last block (10,000 − 8,192), not the waste.
  • B. 2 blocks hold only 8,192 bytes, too little for 10,000.
  • D. 3 blocks hold 12,288 bytes, so 2,288 bytes are unused, not zero.

Tip: Blocks = file size ÷ block size, rounded up; waste = blocks × block size − file size.

Question 6Medium

A disk has 2^20 blocks and uses a bit vector to track free blocks.

How large is the bitmap?

  1. 128 KB
  2. 16 KB
  3. 1 MB
  4. 64 KB

Answer: A. 128 KB

Explanation

One bit per block:
2^20 bits = 2^17 bytes = 128 KB.

Step-by-step solution

  1. Each block needs 1 bit in the bitmap.
  2. 2^20 bits ÷ 8 = 2^17 bytes.
  3. 2^17 bytes = 128 KB. Marked answer: 128 KB.

Why the other options are wrong

  • B. 16 KB holds only 2^17 bits, enough for 2^17 blocks, not 2^20.
  • C. 1 MB would give 8 bits per block, but each block needs only 1 bit.
  • D. 64 KB is half the needed size, enough for only 2^19 blocks.

Tip: Bitmap bytes = number of blocks ÷ 8; with powers of 2, subtract exponents (2^20 ÷ 2^3 = 2^17).

Question 7Medium

A file system has 8 direct pointers and 1 single-indirect pointer per inode, with 512-byte blocks and 4-byte pointers. What is the largest file it can hold?

  1. 4,096 bytes
  2. 69,632 bytes
  3. 65,536 bytes
  4. 135,168 bytes

Answer: B. 69,632 bytes

Explanation

Single indirect = 512/4 = 128 pointers.
Max = (8 + 128) x 512
= 136 x 512
= 69,632 bytes.

Step-by-step solution

  1. Direct pointers: 8 * 512 = 4096.
  2. Single indirect: 512/4 = 128 pointers.
  3. Total blocks: 8 + 128 = 136.
  4. Total size: 136 * 512 = 69,632 bytes.
  5. Final answer: 69,632 bytes.

Why the other options are wrong

  • A. 4,096 bytes counts only the direct pointers; the single indirect block adds 65,536 more bytes.
  • C. 65,536 bytes counts only the indirect block; the 8 direct blocks add 4,096 bytes, giving 69,632 in total.
  • D. 135,168 bytes would need 264 blocks; 8 direct plus 128 indirect blocks gives 136 blocks, or 69,632 bytes.

Tip: Use block size and pointer count to calculate maximum file size.

Question 8Medium

What does the superblock of a UNIX-style file system contain?

  1. The contents of the root directory together with the names and inode numbers of all files on the volume
  2. Each user's password
  3. The boot loader code exclusively
  4. Metadata about the whole file system, such as size, block counts and free lists

Answer: D. Metadata about the whole file system, such as size, block counts and free lists

Explanation

The superblock (volume control block) describes the file system layout; it is critical, so copies are usually kept.

Step-by-step solution

  1. The superblock stores metadata about the file system.
  2. It includes details like size and block counts.
  3. It also keeps track of free blocks and inodes.
  4. This information helps manage the file system efficiently.
  5. The correct answer is Metadata about the whole file system, such as size, block counts and free lists.

Why the other options are wrong

  • A. Root directory contents and inode numbers are stored in directory data, not in the superblock.
  • B. Passwords are kept in account files, not in the superblock of a UNIX-style file system.
  • C. The boot loader is kept in the boot area, not in the superblock.

Question 9Hard

In the "counting" free-space method, each entry records:

  1. The owner of each free block
  2. The address of the first free block and the number of free blocks that follow it
  3. Only the address of the next free block, forming a linked list of free blocks
  4. One bit per block

Answer: B. The address of the first free block and the number of free blocks that follow it

Explanation

Counting exploits the fact that blocks are often freed in contiguous runs, so (start, count) pairs are compact.

Step-by-step solution

  1. Counting stores (first free block, count) pairs.
  2. Contiguous free runs compress into one entry.

Why the other options are wrong

  • A. Owner is not tracked.
  • C. That is the linked-list method.
  • D. That is the bitmap method.

Question 10Hard

With linked allocation, how many disk reads are needed to read block 50 of a file (blocks numbered from 0), given only the address of the first block and nothing cached?

  1. 51
  2. 50
  3. 1
  4. 2

Answer: A. 51

Explanation

Each block holds the pointer to the next, so blocks 0 to 50 must all be read in order: 51 reads.

Step-by-step solution

  1. Block 0 points to Block 1.
  2. Block 1 points to Block 2.
  3. This continues until Block 49 points to Block 50.
  4. To reach Block 50, all blocks from 0 to 49 must be read.
  5. Reading each block requires one disk read, so total reads = 50 + 1 = 51.

Why the other options are wrong

  • B. 50 reads would skip reading block 50 itself; the chain from block 0 to 49 is 50 reads, then block 50 is one more.
  • C. 1 read is only possible if the block is cached or is the first block; with only the first address, the chain must be followed.
  • D. 2 reads would only reach the second block; following the chain to block 50 needs 51 disk reads.

Practise all 31 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Operating Systems topics · All topics