Linux Volume Manager and Filesystems

Linux Volume Manager and Filesystems

Jan 28, 2022 3:49 AM
operating systems

Today I learned a bit more about LVM (Logical Volume Manager) in Linux.

I didn’t have a great understand of how filesystems and disk work and I ran into an issue at work where it would have been valuable to know. At Mighty, we use Linux LVM to manager disk across our virtual machines. An example hierarchy of how physical disk translates to a filesystem looks like this:


The physical volume lives right on top of the physical disks. Several physical volumes can be grouped together to form one volume group like shown in the diagram. The benefit of this is to make higher layers of software feel that it is accessing one large disk rather than several different physical disks. A single physical volume can also have its own volume group.

Above the volume group is logical volumes. The logical volumes allow dividing up the volume group into different chunks that can be mounted onto different paths and file systems. For example, if I have 32gb of total disk space (4 separate 8gb hard drives), I can create a volume group on top of it that spans all 32gb, create two logical volumes on top of it of 8gb each, and mount one on /data/ and one on /. On top of the logical volume, you have file systems. The filesystem determines how the data on disk is formatted.

The lsblk CLI tool will show you the structure of your machine. It’ll show you the hierarchy of disk, volume groups, logical volumes, and file system. You can remove existing logical volumes and volume groups with the lvremove and vgremove tools.