File System Interview Questions: Inodes, Allocation and Disk Scheduling
Last updated 2026-11-19
File systems questions mix concepts you can explain from a diagram (inode, directory, links, journaling) with numericals that are easy to get wrong under pressure: the maximum file size with direct and indirect pointers, the bitmap size for a disk, and total head movement for disk scheduling algorithms. This page works all three, with one disk-scheduling request queue solved by FCFS, SSTF and SCAN.
Linux interviews lean on inodes, links and permissions, so this page pairs well with Linux interview questions and Linux commands interview questions. For the rest of the subject see operating systems interview questions, and for a preparation plan how to crack an OS interview.
| Numericals | Inode maximum file size, bitmap size, FCFS/SSTF/SCAN head movement |
|---|---|
| Queue used | 98 183 37 122 14 124 65 67 with head at 53 |
| Also covered | FAT, journaling, hard vs soft links, RAID levels |
Pointers per block: the number everything depends on
- Pointers per indirect block = block size / pointer size. For a 4 KB block and 4-byte pointers that is 1024.
- Single indirect covers 1024 blocks, double indirect covers 1024 x 1024 blocks, triple indirect covers 1024^3 blocks.
- Maximum file size = (direct + single + double + triple blocks) x block size, also limited by the pointer width and the file-size field.
File System Interview Questions: questions with worked answers
1 What is a file system and what does it provide?
easyA file system organises data on storage into files and directories and keeps the metadata needed to find them (names, sizes, permissions, timestamps, block locations). It provides naming, hierarchical directories, access control, space allocation and free-space management, and caching. Common examples are ext4, XFS and Btrfs on Linux, NTFS on Windows, APFS on macOS and FAT32 or exFAT on removable media.
2 What information does an inode contain? What does it not contain?
easyAn inode holds the file type, permissions, owner and group IDs, size, link count, timestamps (access, modification, change), and pointers to the data blocks. It does not contain the file name; names live in directory entries that map a name to an inode number. That is why one inode can have several names (hard links) and why renaming a file does not change its inode.
3 Compare contiguous, linked and indexed file allocation.
mediumContiguous allocation stores a file in consecutive blocks: fast sequential and direct access, but external fragmentation and difficulty growing a file. Linked allocation chains blocks with pointers: no external fragmentation and easy growth, but slow direct access and loss of a pointer breaks the chain. FAT keeps the links in a table in memory to speed this. Indexed allocation uses an index block (or inode) of pointers: efficient direct access and no external fragmentation, at the cost of index overhead, and large files need multi-level indexes.
4 Numerical: A Unix inode has 12 direct pointers, one single, one double and one triple indirect pointer. Block size is 4 KB and a pointer is 4 bytes. Find the maximum file size.
mediumPointers per block = 4096 / 4 = 1024. Direct: 12 blocks = 48 KB. Single indirect: 1024 blocks = 4 MB. Double indirect: 1024^2 = 1,048,576 blocks = 4 GB. Triple indirect: 1024^3 = 1,073,741,824 blocks = 4 TB. Total is 48 KB + 4 MB + 4 GB + 4 TB, approximately 4 TB (4 TB + 4 GB + 4 MB + 48 KB exactly). In a real system the 32-bit block pointer also limits the addressable disk to 2^32 blocks x 4 KB = 16 TB.
5 Numerical: For the same inode layout, which pointer levels does a 100 MB file use and how many blocks does it need?
medium100 MB / 4 KB = 25,600 blocks. The 12 direct blocks cover 12 and the single indirect covers 1024 more, so 1036 blocks (about 4.05 MB) are reached without the double level. The file needs 25,600 - 1036 = 24,564 more blocks from the double indirect tree, which can hold up to 1,048,576, so the triple level is not used. Overhead blocks: 1 single-indirect block, 1 top double-indirect block and ceil(24564 / 1024) = 24 second-level blocks, so 26 index blocks in addition to the 25,600 data blocks.
6 Numerical: How big is the free-space bitmap for a 1 TB disk with 4 KB blocks?
mediumNumber of blocks = 2^40 / 2^12 = 2^28 = 268,435,456. A bitmap uses one bit per block, so 2^28 bits = 2^25 bytes = 32 MB. A bitmap makes it easy to find contiguous free blocks; the alternative is a linked free list, which uses almost no extra space but is slower to search.
7 What is the difference between a hard link and a soft (symbolic) link?
mediumA hard link is another directory entry pointing to the same inode, so both names are equal, and the data is removed only when the link count falls to zero. Hard links cannot cross file systems and normally cannot point to directories. A soft link is a small file that contains a path to its target; it can cross file systems and point to directories, but it breaks (dangles) if the target is deleted or moved. ln file link makes a hard link and ln -s makes a soft link.
8 What is journaling and why do modern file systems use it?
mediumA crash during a multi-step update (allocate a block, update the inode, update the directory) can leave the file system inconsistent, which previously needed a slow full check (fsck). A journaling file system first writes the intended changes to a log (the journal), then applies them in place, so after a crash it replays or discards the log in seconds. Most file systems journal only metadata (ext4 default ordered mode), while data journaling also protects file contents at a performance cost. ext4, NTFS and XFS journal; Btrfs and ZFS use copy-on-write instead.
9 Numerical: Head at cylinder 53, request queue 98, 183, 37, 122, 14, 124, 65, 67. Find total head movement for FCFS.
mediumFCFS serves requests in arrival order: 53 to 98 = 45, 98 to 183 = 85, 183 to 37 = 146, 37 to 122 = 85, 122 to 14 = 108, 14 to 124 = 110, 124 to 65 = 59, 65 to 67 = 2. Total = 45 + 85 + 146 + 85 + 108 + 110 + 59 + 2 = 640 cylinders.
10 Numerical: Same queue, find the head movement for SSTF.
mediumSSTF always picks the nearest pending request. From 53 the nearest is 65 (12), then 67 (2), then 37 (30), then 14 (23), then 98 (84), then 122 (24), then 124 (2), then 183 (59). Total = 12 + 2 + 30 + 23 + 84 + 24 + 2 + 59 = 236 cylinders. SSTF can starve far-away requests when new nearby requests keep arriving.
11 Numerical: Same queue on a disk of cylinders 0 to 199, find the head movement for SCAN with the head moving toward 0 first.
mediumThe head moves down serving 37 and 14, continues to the end at 0, reverses and moves up serving 65, 67, 98, 122, 124 and 183. Movement down = 53 - 0 = 53, then up to 183 = 183, total = 53 + 183 = 236 cylinders. If the head went to 199 as well (C-SCAN style) the totals would differ, so state the algorithm variant. LOOK would stop at 14 instead of 0: 39 + 169 = 208.
12 Compare SCAN, C-SCAN and LOOK.
mediumSCAN (the elevator algorithm) sweeps the arm from one end to the other, serving requests on the way, then reverses. C-SCAN sweeps in one direction only, and on reaching the end jumps back to the start without serving on the return, giving more uniform waiting times. LOOK and C-LOOK are variants that go only as far as the last request in each direction instead of the disk end. On SSDs there is no head, so these algorithms matter little and simple schedulers like noop or mq-deadline are used.
13 What are the common RAID levels?
mediumRAID 0 stripes data across disks for speed with no redundancy. RAID 1 mirrors data, so it survives one disk failure at 50 percent capacity. RAID 5 stripes data with distributed parity, survives one failure, and gives (n - 1) disks of usable space. RAID 6 uses double parity and survives two failures. RAID 10 stripes over mirrored pairs for speed and redundancy, with 50 percent usable capacity. For example, four 2 TB disks give 8 TB (RAID 0), 4 TB (RAID 1 or 10) or 6 TB (RAID 5).
14 Explain the layers a read() call goes through, including the VFS and the buffer cache.
hardThe application calls read on a file descriptor. The kernel looks up the open-file entry and calls through the virtual file system (VFS), a common interface that dispatches to the concrete file system (ext4, NFS). The page cache is checked first; on a hit data is copied to the user buffer without touching the disk. On a miss the file system maps the file offset to disk blocks via the inode, the block layer queues and merges the I/O requests under an I/O scheduler, the driver talks to the device, and on completion an interrupt wakes the process. Read-ahead prefetches following blocks for sequential access.
15 Compare FAT, ext4 and NTFS at a high level.
hardFAT keeps a file allocation table of block chains; it is simple and universally supported, but has no permissions or journaling, FAT32 limits files to under 4 GB, and it fragments. ext4 uses inodes, extents (ranges of blocks instead of per-block pointers), journaling, delayed allocation and large volumes. NTFS stores everything, including metadata, as files in the master file table, supports ACL permissions, compression, encryption, journaling and large files. exFAT replaces FAT32 for removable media.
Frequently asked questions
What is the difference between absolute and relative paths?
An absolute path starts at the root directory (/home/user/a.txt) and means the same wherever you are. A relative path is resolved from the current working directory, so ../a.txt depends on where the process is running.
What happens when you delete a file in Linux?
rm removes the directory entry and decrements the inode's link count. The inode and data blocks are freed only when the link count is zero and no process still has the file open, which is why deleting a large log file that a process holds open does not free disk space until the process closes it.
Why can a disk be full while df shows free inodes, or the reverse?
Space and inodes are separate resources. Millions of tiny files can use all inodes while blocks remain free, and a few huge files can use all blocks while inodes remain. df -i shows inode usage.
What is a file descriptor?
A small non-negative integer that indexes a process's table of open files. 0, 1 and 2 are standard input, output and error by convention.
Related guides
- Linux Interview Questions and Answers: Concepts, Permissions and Processes
- Linux Commands Interview Questions with Examples
- Operating Systems Interview Questions with Worked Answers
- Memory Management Interview Questions with Numericals
- Paging and Virtual Memory Interview Questions with Numericals
- Shell Scripting Interview Questions with Bash Examples
More in CS Fundamentals Interview Questions
- Git Interview Questions and Answers with Commands
- HTTP and HTTPS Interview Questions: Methods, Status Codes, TLS and Caching
- Inheritance and Polymorphism Interview Questions
- IP Addressing and Subnetting Interview Questions with Worked Solutions
- Linux Commands Interview Questions with Examples
- Linux Interview Questions and Answers: Concepts, Permissions and Processes
- Load Balancing Interview Questions and Answers
- Low-Level Design Interview Questions with Code
- Memory Management Interview Questions with Numericals
- Message Queue and Kafka Interview Questions
- Microservices Interview Questions and Answers
- MongoDB Interview Questions and Answers