THINK FIRST·CODE LATER

← All labs

Linux in practice: inodes, links, caches and fsync

Problem

On Linux, explore the file system and measure storage behaviour. Record commands and outputs.

  1. Create a file, a hard link and a symbolic link. Use ls -li and stat to show inode numbers and link counts. Delete the original and explain what happens to each link.
  2. df -h and df -i: explain the difference. Create 100,000 empty files in a directory (a small script) and observe df -i. Why can a disk be "full" with free space left?
  3. Write 1 GB with dd if=/dev/zero of=test bs=1M count=1024 and then with oflag=direct or conv=fsync. Compare the reported speeds and explain the difference using the page cache.
  4. Write a small program that appends 1,000 small records to a file, (a) without fsync, (b) with fsync after each record, (c) with fsync every 100 records. Measure the time of each. Relate the result to database group commit.
  5. lsblk -d -o NAME,ROTA,SIZE and cat /sys/block/<dev>/queue/scheduler: is your disk rotational? Which I/O scheduler is used, and is it appropriate?

Work it out on paper, in a document or here, then compare with the model answer. Your answer stays in your browser — it is never sent to or stored on the server.