Linux Labs

Storage / Stage 2 of 11

Mounting and fstab

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 7 · on a machine · 4 min

The night report is gone

What you will learn

  • Check which filesystem serves a directory with findmnt and df.
  • Match an fstab entry against the volume with blkid and check the table before mounting.
  • Mount a volume without losing files that were written to the directory without it.

A service stores its reports in /mnt/lab-data, where a separate volume is supposed to be mounted. Last night nobody mounted the volume, the service did not notice and wrote report-0915.txt as usual.

In the morning you mount the volume with mount and unmount it with umount. Watch what happens to the directory.

Exercise · look

Mount the volume and look at the directory

Read the night report in /mnt/lab-data, mount the volume from the file /srv/storage-lab/disk.img there and look at the directory. Then unmount the volume and look at the directory again.

First, predict

What will ls show right after the volume is mounted?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

Where was report-0915.txt while the volume was mounted?

  • Neither mount nor umount deletes files or keeps copies: after umount the report is in its old place with its old text.

  • Had the report been on the volume, ls would have shown it next to archive while the volume was mounted. It was not there.

  • The report is a file on disk: cat read it before the volume was mounted, and ls found it in the same directory after unmounting.

The report stayed in the directory on the root filesystem the whole time, and the mounted volume covered it.

Ubuntu 24.04
Loading…