1. Overview
In this tutorial, we’ll look at the differences between drives, partitions, and volumes in Linux.
2. Computer Storage
In the realm of computer storage, there are two primary types: the primary storage and the secondary storage.
Primary storage usually refers to the volatile memory that temporarily stores data while the system operates, such as random access memory (RAM).
On the other hand, secondary storage refers to the non-volatile type that provides long-term storage for digital data.
Documentations or articles in the wild seem to refer to secondary storage with several terms, such as drive, partition, and volume. Let’s look at the meaning of each term and the differences between them.
3. Drive
A drive, in the context of Linux, refers to a physical storage device that can store data. Specifically, it refers to a single physical unit of digital storage media, such as a hard disk drive or a solid-state drive (SSD). Unlike partitions and volumes, the word itself doesn’t imply any form of logical division or grouping of storage.
Etymologically, the word comes from the physical driver that rotates the disks of the storage for seeking purposes. In early days, non-volatile computer storage consisted of spools of magnetic strips mounted onto a tap driver. As the storage technology advanced, the drive mechanism seems to have stuck around as we can see in the floppy disk and hard disk drive.
Although newer storage device such as SSD no longer has a moving driver, the word “drive” is still used. Specifically, people continue to use the word “drive” to refer to the actual physical storage device, be it a spinning hard disk drive or an SSD.
Linux represents the drives as pseudo files with the prefix sd under the /dev directory. For example, the first physical drive we attach to the system will be /dev/sda. For the subsequent physical storage drive we attach to the system, they’ll get the identifier in the form of sd{alphabet}, where alphabet is the next alphabet in line.
4. Partitions
Partition is a logical division or subdivision of a physical storage drive. Specifically, given a single physical storage drive, we can divide it into several smaller independent and isolated units of storage, known as partitions.
The key distinction between a partition and a drive lies in their relationship and functionality. While a drive represents the physical storage device itself, a partition is an abstraction layer on top of that drive, serving as a logical division within it.
For example, we can divide a single 1TB physical SSD we have in the system into two different partitions. Then, the system can treat the two partitions as separate storage mediums, each with 500GB of storage space, if we partition the drive equally.
One benefit of partitioning a physical storage drive is that the partitions are independent and isolated. The isolation of different partitions means that we can install different operating systems onto the same drive under different partitions.
Besides that, with the partitions being separate storage entities, we can also format the partitions with a different file system from one another. This means we can afford to install multiple operating systems onto the same physical storage drive by partitioning.
To manage the partitions on a storage drive, Linux stores meta-information about the partitions in a partition table. Then, the system stores the partition table as the header in the physical storage drive, commonly known as sector 0 of the drive. In Linux, the most common partitioning table formats are the Master Boot Record (MBR) and the GUID Partition Table (GPT).
Besides that, command-line tools like fdisk and parted are popular tools for partitioning a drive.
5. Volumes
A volume in computer data storage refers to a single accessible storage area that contains a single file system. Generally, this storage area resides on a single partition of a hard disk, although it may not always be the case.
In Linux specifically, volume refers to the logical grouping of storage that’s managed by the logical volume management (LVM) tool. In this context, all the physical storage devices are known as Physical Volume (PV). Additionally, these PVs don’t necessarily need to be an actual physical storage device attached to the system, they can be backed by a network storage device as well.
Then, these PVs can be attached to one or more volume groups (VGs). The volume group is a way to group the actual storage device into logical units for further demarcation. Through these VGs, we can create logical volume (LV) out of the pool of backing storage.
The idea is that from the application perspective, the volume provides a similar interface for interacting with storage, regardless of whether it’s spanning across multiple physical storage drives, or is actually a network storage.
One advantage the volume construct offers is the more flexible management of storage devices. For example, we can resize a volume dynamically whenever we add or retire a physical storage drive.
6. Conclusion
In this article, we looked at the different terminologies that are always associated with non-volatile computer storage.
Firstly, we learned that the drive is commonly used to refer to an actual physical storage device. Examples of these devices are hard-disk drives and solid-state drives.
Then, we saw that partitions are subdivisions of a single physical storage drive. It offers the flexibility to divide a large physical storage device into a few smaller independent storage units.
Finally, we understood that the volume is a higher level of abstraction over the partition. Specifically, the volume helps us in managing our storage in the form of aggregated storage space, instead of the individual storage device.