Linux Advanced File System and Storage 4 — Questions and Answers
Question 1: What is the default inode ratio when creating an ext4 filesystem with mkfs.ext4?
- One inode per 16KB of space (Correct answer)
- One inode per 4KB of space
- One inode per 1MB of space
- One inode per 8KB of space
Correct answer: One inode per 16KB of space
By default, mkfs.ext4 creates one inode for every 16384 bytes (16KB) of filesystem space, balancing inode count against overhead.
Question 2: Which command shows I/O statistics per block device in real time?
- iostat -x (Correct answer)
- iotop -b
- blktrace
- hdparm -tT
Correct answer: iostat -x
iostat -x from the sysstat package reports extended I/O statistics including utilization, await time, and throughput per device.
Question 3: In Linux software RAID (mdadm), what does the '--spare-devices' option specify?
- Number of hot-spare drives to add to the array (Correct answer)
- Number of failed devices allowed
- Number of partitions per disk
- Sync speed limit for spare rebuilds
Correct answer: Number of hot-spare drives to add to the array
The --spare-devices option in mdadm specifies how many hot-spare drives are included in the RAID array for automatic failure recovery.
Question 4: What is the purpose of the 'barrier=0' mount option for ext4?
- Disables write barriers, improving performance at the cost of data integrity on power loss (Correct answer)
- Disables journaling barriers only
- Sets the I/O scheduler barrier count to zero
- Disables the filesystem barrier cache
Correct answer: Disables write barriers, improving performance at the cost of data integrity on power loss
Disabling write barriers (barrier=0) improves write performance but can lead to filesystem corruption if power is lost before data is flushed.
Question 5: Which xfs_repair option performs a dry run, reporting errors without making changes?
- -n (Correct answer)
- -d
- -L
- -f
Correct answer: -n
xfs_repair -n runs in no-modify mode, scanning the filesystem and reporting what would be repaired without actually making any changes.
Question 6: What does 'copy-on-write' (CoW) mean in the context of Btrfs?
- Modified data is written to a new location, leaving the original intact until the transaction commits (Correct answer)
- Files are copied before any write operation
- The filesystem copies blocks from RAM before writing
- Write operations are mirrored to two locations simultaneously
Correct answer: Modified data is written to a new location, leaving the original intact until the transaction commits
In Btrfs CoW semantics, when data is modified, new blocks are allocated and written first; old blocks are freed only after the new write is committed.
Question 7: Which /sys path exposes the I/O scheduler currently active for a block device (e.g., sda)?
- /sys/block/sda/queue/scheduler (Correct answer)
- /proc/sys/block/sda/scheduler
- /sys/class/block/sda/ioscheduler
- /proc/block/sda/queue
Correct answer: /sys/block/sda/queue/scheduler
The active I/O scheduler for a block device is shown and changed via /sys/block/<dev>/queue/scheduler, where the current scheduler appears in brackets.
What is the default inode ratio when creating an ext4 filesystem with mkfs.ext4?