Authors Top

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

In this article, we’ll cover some questions that can arise when starting to manage Linux systems. For example, when installing Linux, we might specify partitions and mounting points that we want to create. However, does Linux create other partitions/mounting points on its own? Are mounting points always related to partitions, or can we mount other things?

Although these questions might seem straightforward, their formulation already includes misconceptions. But before continuing with the explanations, let’s clarify some concepts.

2. What Are Partitions?

We can understand partitions as portions of the disks dedicated to specific goals. We can have multiple partitions that we can use for purposes such as:

  • A filesystem is just a way to present information in a hierarchical structure. This is the most common use of a partition. On the one hand, we can then use this filesystem to save our documents. There are multiple filesystems types, as they manage the file trees in different ways. We can find filesystems backed both on disks (as ex2 or XFS) or networks (as NFS or Samba). On the other hand, we can also find filesystems that display information about the kernel, like the procfs that displays the process information in a hierarchical way, being more convenient and organized than kernel memory.
  • Storage virtualization, having a partition is a container for other partitions. A single hard drive has a limited number of extended partitions, but we can subdivide these extended partitions into logical partitions. Within storage virtualization, the best well-known framework is Logical Volumen Management (LVM).
  • Swap and direct application access space. We can create a partition to allocate space for saving the hibernation images or for memory paging. Memory paging, also known as swapping, is when the system uses a storage device as a partition to save and get data to use in the main memory.

3. Mounting Filesystems

We’ve already discussed what partitions are and what we can use them for. Moreover, we introduced different filesystems that we can set up in our partitions. We’ll now discuss how Linux handles this. To avoid confusion, let’s write file-system to discuss the Linux file directory tree where we see everything displayed. Alternatively, the filesystem is what our partitions have, as described before.

3.1. What is Mounting a Filesystem?

The Linux file-system is based on the root directory, located in /. During startup, the kernel creates this file-system before starting other processes. Within this file-system, the Linux kernel starts to create directories that will point to filesystems. These are folders such as /home/proc, or /dev.

After the folder creation, the mounting operation associates a directory in the file-system with a filesystem. Therefore, every filesystem should be mounted before accessing it. This means that before accessing data in a filesystem, we need to mount it and link the storage device (filesystem) with a directory in the directory tree (file-system).

Let’s give an example to clarify this. We split the hard drive into two partitions: one for swapping and the other for file storage. The second one has a filesystem of type ex2 that stores a file named foo.txt located under a directory named folder. This yields /folder/foo.txt within the filesystem of the second partition of the hard drive. To access this file, we need to mount the filesystem into a folder located under the / folder of our Linux file-system directory tree, for example, /mnt. Thus, the file will appear in our Linux file-system directory as /mnt/folder/foo.txt.

As a side note, we can access the same filesystem from different file-system directory paths. We need bind mounts to do that.

3.2. What Filesystems Are There Mounted in My System?

We can use different tools, such as findmnt, to list all the mounted filesystems in our system:

$ findmnt -oTARGET,SOURCE
TARGET                                                  SOURCE
/                                                       /dev/sda5
├─/proc                                                 proc
│ └─/proc/sys/fs/binfmt_misc                            systemd-1
├─/sys                                                  sys
│ ├─/sys/kernel/security                                securityfs
│ ├─/sys/fs/cgroup                                      cgroup2
│ ├─/sys/fs/pstore                                      pstore
│ ├─/sys/fs/bpf                                         bpf
│ ├─/sys/kernel/config                                  configfs
│ ├─/sys/kernel/debug                                   debugfs
│ ├─/sys/kernel/tracing                                 tracefs
│ └─/sys/fs/fuse/connections                            fusectl
├─/dev                                                  dev
│ ├─/dev/shm                                            tmpfs
│ ├─/dev/pts                                            devpts
│ ├─/dev/hugepages                                      hugetlbfs
│ └─/dev/mqueue                                         mqueue
├─/run                                                  run
│ ├─/run/credentials/systemd-sysctl.service             ramfs
│ ├─/run/credentials/systemd-tmpfiles-setup.service     ramfs
│ └─/run/user/1000                                      tmpfs
│ └─/run/user/1000/gvfs                                 gvfsd-fuse
├─/tmp                                                  tmpfs
└─/home                                                 /dev/sda6

We’ve requested two outputs. The TARGET is the mounting directory in the file-system. The SOURCE points to the source device. This is either another directory in the /dev folder of the file-system or a filesystem directly.

3.3. Filesystems Mounted by Default

We can see from the previous command output that there are many mounted filesystems – even if we’ve mounted none of those manually. A Linux file-system mounts, by default, many filesystems at startup. Different distributions of Linux may have different mounted filesystems serving different purposes, but the most common ones are:

  • The root of the file-system /, where we can find everything. The kernel mounts it during startup, and the bootloader select which disk partition filesystem to use (in the previous example /dev/sda5).
  • The /proc filesystem contains information about the processes and other kernel parameters.
  • The /sys filesystem with information about hardware devices.
  • The /dev filesystem contains the devices. The utility udev populates it, automatically creating entries based on available hardware. This contains other filesystems, for example,/dev/pts contains details for terminal emulators.

Even if those filesystems always appear, we can have other mounting points (and therefore, other filesystems mounted). For example, if we automatically mount an external drive with the mount tool, it will also appear after starting up our system. Also, other services, such as the NFS server, might mount extra filesystems.

The case of the swapping partition is special. Swap is not a filesystem. We don’t need to mount it, and the kernel doesn’t mount it automatically. Swap is only a partition that the system uses as extra memory for paging.

Moreover, we can customize the location where our filesystems appear in the directory file-system. However, there are some file-system directories that we cannot use for our devices. For example, the /proc directory of the file-system always points to the procfs. Therefore, we can neither mount our external hard drive in the /proc directory nor change where the filesystem procfs is. 

4. Answering the Original Questions

After defining some concepts and seeing their relationship, let’s return to the original questions.

The first question asked whether Linux creates partitions or mounting points on its own. When installing Linux, we can create as many partitions as we want to divide the hard drive as we please. On those partitions, we can create filesystems and mount those filesystems. Linux on its own doesn’t create new partitions. However, Linux mounts many filesystems on mounting points that are predefined. For example, we see the /proc mounting point that Linux links to the procfs filesystem.

Regarding the second question, we don’t mount partitions, we mount filesystems. This is important because we can mount filesystems that don’t exist on partitions – such as procfs. So, we can say that mounting points are always related to filesystems, regardless of whether they are in a physical partition.

5. Conclusion

In this article, we’ve talked about three things: partitions, filesystems, and mounting. We’ve clarified two common questions when handling Linux systems. The first is that Linux mounts many filesystems that we don’t create but doesn’t create partitions for us. The second is that we mount filesystems that can be in partitions or not.

Authors Bottom

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

guest
0 Comments
Inline Feedbacks
View all comments