Basic storage abstractions on Linux
Published: Sat Feb 10 2024
Topics: linux
Some of the first concepts you come in contact with when installing and using a GNU/Linux distribution for the first time are those related to storage. I would have saved a lot of time in my projects with linux if I had studied the fundamentals of storage sooner.
The following is a condensed and simplified summary of five concepts that you will need in order to better understand Linux (and most other OS’s). Hence, this will be useful for working with personal computers, bare metal servers, virtual machines, docker containers, IoT devices, etc.
Here is a list, ranging from the most concrete to the most abstract:
- Drive: Physical storage medium or device
- Disk: OS representation of a drive
- Partition: Contiguous part of a disk
- Volume: Formatted partition
- Image: Snapshot of disk, partition or volume
Let’s elaborate on each one.
Drive
A physical device that has the capability of storing raw (digital) data. It is the physical substrate that contains the immaterial data. The more correct name for it would be storage medium or device.
Sometimes it is used informally to refer to any of the other categories. It's a mess, I know 🤦♂️️.
There are two main types of storage technology:
- HDD: Hard Disk Drives. It uses magnetic storage on a spinning metal disk.
- SSD: Solid State Drives. It uses flash memory, that is, chips (silicon transistors aka MOSFETs) to store bits.
Disk
It is the representation of the Drive within an operating system, like Linux.
The OS assigns a name to each disk.
On Linux, the most common names are:
sdx
for SSD drives,hdx
for HDD drives,
where x is an letter beginning from a
🧱 Example:
A linux computer with two SSDs and one HDD will have disks named as follows:
sda
,sdb
andhda
On Windows, all regular hardware disks have the ‘disk’ prefix followed by an integer starting from 0
🧱 Example:
A Windows computer with two SSDs and one HDD will have disks named as follows:
disk0
,disk1
,disk2
A disk has a special sector or place for the partition table: a data structure that defines how the disk is divided into one or more partitions.
The partition configuration of a disk can be implemented with any of several existing partition schemes. The most popular are:
- MBR (Master Boot Record):
- It can only handle four primary partitions and 2TB of HDD space
- GPT (GUID Partition Table):
- It has no partition limit.