ubuntu, updated

How disks, partitions and volumes fit together

The layers between a physical disk and a folder you can write to: disks, partitions, LVM, file systems and mount points.

The layers

Between the hardware and a folder like /data there are up to five layers. Each one has its own tool.

flowchart LR
    D["Disk
/dev/sdb"] --> P["Partition
/dev/sdb1"] P --> PV["LVM
PV → VG → LV"] PV --> FS["File system
ext4 / XFS"] FS --> M["Mount point
/data"]
LayerWhat it isTool
DiskThe physical or virtual drive: /dev/sda, /dev/nvme0n1, /dev/vdalsblk
PartitionA slice of a disk with fixed start and end: /dev/sda1parted, fdisk, growpart
LVM (optional)A flexible layer that pools disks and cuts them into volumespvcreate, vgcreate, lvcreate
File systemThe structure that stores files and foldersmkfs.ext4, mkfs.xfs
Mount pointThe folder where the file system appearsmount, /etc/fstab

You can skip layers. A data disk can be formatted without a partition or LVM. But the order always stays the same, and to grow something you grow it bottom-up: disk, then partition, then LVM, then the file system.

Partitions

A partition table at the start of the disk describes the slices. Use GPT (modern, many partitions, disks over 2 TB). The old MBR/msdos format is only for legacy systems.

Partitions are rigid: a partition can only grow into free space directly behind it.

LVM: the flexible layer

LVM (Logical Volume Manager) is the reason Ubuntu Server’s default install is easy to grow. It has three parts:

PartShortThink of it as
Physical VolumePVA disk or partition handed to LVM
Volume GroupVGA storage pool built from one or more PVs
Logical VolumeLVA “virtual partition” cut out of the pool, where the file system goes
flowchart TB
    subgraph VG["Volume Group: ubuntu-vg"]
      PV1["PV /dev/sda3"]
      PV2["PV /dev/sdb"]
    end
    VG --> LV1["LV ubuntu-lv
mounted at /"] VG --> LV2["LV data
mounted at /data"] VG --> F["free space"]

Why use it?

LVM volumes show up as /dev/VGNAME/LVNAME and /dev/mapper/VGNAME-LVNAME. Both point to the same thing.

Note: The Ubuntu installer creates ubuntu-vg/ubuntu-lv but often uses only part of the disk (max. 100 GB by default). Check sudo vgs: the free space can be added in one command. See Extend a disk or volume.

File system and mount

A fresh partition or LV is just empty blocks. Formatting (mkfs) writes a file system onto it. Mounting attaches it to a folder. Mounts made with mount are gone after a reboot; to make them permanent, add them to /etc/fstab.

Which file system? See File systems compared.

Where to go next

§ home
~/knubertus/home/
1,1 Top