Make a Mount Permanent with fstab

Linux lab Intermediate 4 tasks 20 points

A data disk should mount itself at /mnt/store every time the machine boots, not just when you run mount by hand. The disk, data.img, is already formatted as ext4. Add it to /etc/fstab by UUID with the nofail option, then mount it with a single mount -a. Password: student.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

Capture the UUID in a variable: UUID=$(sudo blkid -s UUID -o value /dev/loop0).

Append the line with echo "UUID=$UUID /mnt/store ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab, then sudo mount -a.

Solution explanation

Entries in /etc/fstab are mounted at every boot. You read the disk's permanent UUID with blkid and add a six-field line: the UUID= device, the mount point /mnt/store, the type ext4, the options defaults,nofail, and the two 0 2 flags. UUID= is used instead of /dev/loop0 because device names can change but the UUID can't. sudo mount -a then mounts everything in fstab, applying the new line at once.

Show solution
sudo losetup -fP --show data.img
sudo blkid /dev/loop0
UUID=$(sudo blkid -s UUID -o value /dev/loop0)
echo "UUID=$UUID  /mnt/store  ext4  defaults,nofail  0 2" | sudo tee -a /etc/fstab
sudo mkdir -p /mnt/store
sudo mount -a
findmnt /mnt/store
HOME LEARN COMMUNITY DASHBOARD