Files
mkdocs-wiki/docs/linux/lvm2.md
T
2024-06-30 14:11:32 +00:00

6.6 KiB

LVM2 (Logical Volume Manager 2)

LVM2 (Logical Volume Manager 2) is a utility for managing disk storage in Linux. It allows you to manage disk space efficiently by abstracting physical storage devices into logical volumes. It provides features like volume resizing, snapshotting, and striping, making it flexible and scalable for various storage needs.

  1. Physical Volume: Represents the physical storage devices (e.g., hard drives, SSDs) that are part of the storage pool managed by LVM.

  2. Volume Group: Combines multiple physical volumes into a unified storage pool, enabling easy management and allocation of logical volumes.

  3. Logical Volume: Serves as a virtual disk that can be used for various purposes, such as creating partitions, mounting file systems, or even setting up RAID configurations.

  4. File System: Represents the data organization and access methods used to store and retrieve data on a logical volume. Common file systems include EXT4, XFS, and Btrfs.

Physical Volume (PV)

A Physical Volume (PV) in LVM is a physical storage device or partition used by LVM. It is a building block for creating Volume Groups and Logical Volumes, allowing you to manage storage efficiently. This command creates the PV on the devices, you can do multiple at a time.

sudo pvcreate /dev/Device /dev/Device2

The pvdisplay command provides a output for each physical volume. It displays physical properties like size, extents, volume group, and so on in a fixed format.

sudo pvdisplay

The pvscan command scans all physical volumes (PVs) on the system and displays information about them.

sudo pvscan

Moves the allocated physical extents from one physical volume to another. Useful when you need to redistribute space between physical volumes in a volume group. After a crash or power failure this can be finished without a problem.

sudo pvmove /dev/source_device /dev/target_device

Volume Group (VG)

A Volume Group (VG) in LVM is a collection of one or more Physical Volumes (PVs) combined into a single storage pool. It allows flexible and efficient management of disk space, enabling easy allocation to Logical Volumes (LVs) as needed.

Creates a volume group with a specified name.

sudo vgcreate Volume_Name /dev/Device1 /dev/Device2 ...

The vgdisplay command displays volume group properties (such as size, extents, number of physical volumes, and so on) in a fixed form.

sudo vgdisplay

The vgs command provides volume group information in a configurable form, displaying one line per volume group. The vgs command provides a great deal of format control, and is useful for scripting.

sudo vgs

Logical Volume (LV)

A logical volume in LVM is a flexible virtual partition that separates storage management from physical disks. This creates a logical volume out of the Volume Group with the specified name and size (5GB).

sudo lvcreate -n Volume -L 5g Group