The following tries to provide a simplified overview of how mounting works in the open source unix like world. The page makes claims about other software and standards, these are based at .
Each hardware storage device is separated into partitions. A partition is a fixed space on a storage device where data can be written to and read from. A storage device can also contain only one partition spanning all of its available space.
Mounting is the process of making
a partition accessible to userspace software.
For userspace software to be able to read and write
from and to partitions,
they need to be mounted with a filesystem.
The first filesystem to be mounted
and the most important one,
is the so called root filesystem.
The root filesystem is already mounted
read-only when init is started.
It begins at /
with a tree-like structure and
every subfolder to it can be
used to mount another filesystem.
As an example:
say there are the physical storage medium
sda and sdb,
with corresponding partitons
sda1 and sda2.
If the root filesystem lives on
sda1, sda1
is mounted at /,
that means all data that is written
to or read from files in
the folder /
or any subfolder, e.g. /test,
is saved on sda1.
Suppose now, that additionally
sdb1 is mounted at /mnt/drive.
Now anything that is written to /mnt/drive
and any of its subdirectories lands on sdb1
while everything else below /
lands on sda1.
/ # sda1 is mounted here
├── dev # goes into sda1
├── mnt # goes into sda1
│ └── drive # sda2 is mounted here
│ ├── data1 # goes to sda2
│ └── data2 # goes to sda2
├── package # goes into sda1
├── test # goes into sda1
└── usr # goes into sda1
└── lib # goes into sda1
All partitions are accesible via a corresponding
device node at /dev.
There are multiple naming conventions, differing
between Linux and the BSDs.
As an example, SSDs are named
sdaY, sdbY, ...
on Linux.
Here, a, b, ...
is enumerating the different drives,
while Y enumerates
the different partitions of each drive.
The problem is the following:
On most UNIX like systems the enumeration of
drives is not stable,
that is, it can change depending on the order
in which the UEFI/BIOS detects the hardware.
As an example:
On a Linux system running on a machine with
two SSD's R and S;
R can be available at /dev/sda
and S at /dev/sdb
and after a reboot,
R might be available at /dev/sdb
and S at /dev/sda.
There are multiple approaches to this problem:
After that, the UUID, PARTUUID or label can be given
to a tool like findfs (on Linux)
which will return the device node path /dev/sdXY
When using some
userspace device managers,
there may be symlinks at
/dev/disk/by-id, /dev/disk/by-label
and some more.
by-id, by-label, by-partuuid
and by-uuid
can be considered stable and safe to be used for mounting.
There are the two main approaches on mounting partitions:
mount /dev/XY /path/to/mountpoint
for all devices X
and partitions Y.
/etc/fstab
which contains instructions on
how and where to mount each partition.
Then run mount -a
to have mount parse /etc/fstab
and mount the partitions accordingly.