Linux Labs

Storage / Stage 2 of 11

Mounting and fstab

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · on a machine · 7 min

An fstab entry

To have a volume mounted automatically, you list it in a table. Here is how to read an entry and match it against the volume.

fstab is the filesystem table: what to mount, where and how. The system one lives in /etc/fstab: the system mounts its volumes at boot, and sudo mount -a does it on demand. The lesson uses a separate table, /srv/storage-lab/fstab, which plays no part in booting the machine.

One line describes one filesystem in six space-separated fields:

text
UUID=cfb4161a-…  /mnt/lab-data  ext4  defaults  0  2
Field What it holds
source what to mount: UUID=…, a device, or an image file with the loop option
mount point where to mount it
type the filesystem: ext4, xfs
options defaults is the usual set, ro means read-only
two numbers 0: no dump backup; 2: check after the root filesystem

The source is usually given as a UUID, an identifier the filesystem receives when it is created. A name like /dev/loop0 or /dev/vdb depends on the order devices appear in and may go to another volume after a reboot, while the UUID stays with the filesystem. blkid prints it. mount looks the UUID up among attached devices, which is why the exercises attach the image as a loop device beforehand.

Note

Data volumes get the nofail option: if such a volume is missing at boot, the system boots without it instead of stopping in emergency mode.

In the exercise the table already exists, but the volume will not mount from it.

Exercise · look

Check the line against the volume

Read the training table /srv/storage-lab/fstab and compare its line with what blkid knows about the volume /srv/storage-lab/disk.img. Change nothing.

Sign in and start The machine is available after signing in
Ubuntu 24.04
Loading…