Linux Labs

Storage / Stage 2 of 11

Mounting and fstab

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 7 · on a machine · 7 min

When the service has already written to the directory

An fstab error is often noticed after the service has already written files to the directory without its volume. Here is how to mount the volume without losing them.

A healthy volume with a wrong reference in the table is fixed by fixing the table. mkfs creates a new empty filesystem on the volume and wipes the data. fsck looks for filesystem damage, and a foreign UUID causes none; on a mounted filesystem it can cause damage itself.

Files the service wrote without the volume sit in the directory on the root filesystem. After mount the volume covers them: the service cannot see them, yet they still take space on the root filesystem. So you move them out of the directory before mounting and put them on the volume afterwards.

Check yourself 1 question

A data volume will not mount: its fstab line has the wrong UUID, and the volume itself is healthy. What do you do?

  • The volume stays mounted until a reboot: the table still points at the wrong UUID, so at boot the volume is not found again.

  • fsck looks for filesystem damage, and there is none: findmnt --verify points at a source that does not exist on the machine.

  • mkfs creates a new empty filesystem: the data is lost, and the volume gets a new UUID. The error is in the reference, so fix that.

A healthy volume with a wrong reference is fixed by fixing the reference. findmnt --verify confirms the table, and findmnt --mountpoint plus the volume's files confirm the result.

Sometimes the volume is already mounted and the files are left under it. While the volume is mounted they are out of reach, so you have to unmount it. umount fails with target is busy if something is using the volume, for example your shell sitting inside the directory. Leave it (cd ~) and try again.

In the exercise a colleague has already fixed the table and mounted the volume, and two night reports are left under it.

Exercise · do it

Get the reports out from under the volume

In the morning a colleague fixed the /srv/storage-lab/fstab table and mounted the volume at /mnt/lab-data from it. The night reports report-0915.txt and report-0916.txt stayed under the volume. Move them onto the volume so the service sees them in /mnt/lab-data next to archive, and mount the volume back from the table.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Get the night reports out from under the volume not done yet
  • Mount the volume and put the reports on it not done yet

Step goals

0 of 2
  • Get the night reports out from under the volume — not done yet
  • Mount the volume and put the reports on it — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Get the night reports out from under the volume — not done yet
  • Mount the volume and put the reports on it — not done yet
Loading…