Mounting a volume moves no files. It changes what the path shows, and you can check that.
Attaching a filesystem to a directory is called mounting it. The directory that opens onto its contents is the mount point. While the volume is mounted, the path /mnt/lab-data leads to the volume's root. The directory's own files stay on the root filesystem: the volume covers them, and after umount they are visible again. That is what happened to the night report.
The training volume is the image file /srv/storage-lab/disk.img with ext4 inside. A filesystem lives on a block device, such as a disk or a partition. A regular file is not one, so mount attached the image as the loop device /dev/loop0 and mounted that.
findmnt shows what stands behind a directory in two modes:
| Command | What it shows |
|---|---|
findmnt --mountpoint PATH |
whether anything is mounted exactly at this directory; if not, no output |
findmnt --target PATH |
which filesystem serves the path, even for an ordinary directory |
Your home directory has no volume of its own:
df -h PATH shows the same as --target: its Mounted on column shows the mount point of the filesystem the path lives on.
A service writes to /data. findmnt --mountpoint /data prints nothing, while findmnt --target /data shows TARGET /. Where do its files go?
-
An ordinary directory accepts files: that is how the service wrote
report-0915.txtat night. Check withls /dataanddf -h /data. -
findmnt --mountpoint /datafound nothing: nothing is mounted at /data, so there is no volume there. -
There is no buffer for an unmounted volume: files land straight in the directory on the root filesystem, and after
mountthe volume covers them.
While nothing is mounted at /data, it is an ordinary directory on the root filesystem, and the files land there. Once the volume is mounted they end up under it, like the night report at the start of the lesson.
Key points
- A mounted volume covers the directory's files without deleting or moving them.
-
findmnt --mountpointchecks for a mount exactly at the directory, whilefindmnt --targetanddfshow the filesystem that serves the path.