Logical Volume Management

Logical Volume Management

Table of Contents

  • What is LVM?
  • Conceptions
  • How to
    • create PV
    • create VG
    • create LV


1 What is LVM?

LVM stands for Logical Volume Management, which is one kind of virtual disk partition. In the traditional way, We need to separate a disk into multiple partitions, then format that partition with a filesystem. Once you write the partition table to the disk, rewrite this table will lose all your disk data.

But, LVM gave more scalable and dynamic options, we can adjust and re-create partitions without reboot and re-mount process.

2 Conceptions

  • VG:  Volume Groups
  • PV:  Physical Volumes
  • LV:  Logical Volumes
Volume Groups is a collection of Logical volumes, and it is created on top of physical volumes, Physical Volumes are physical disk partitions with LVM header. Logical Volumes are the final partitions that we can format with our favorite filesystem.

Topology of these concepts:
  • one Volume Group can include more than one Physical Volumes;
  • one Physical Volume can only belong to one Volume Group;
  • one Volume Group can have multiple Logical Volumes;
  • one Logical Volume can only belong to only one Volume Group;
We can conclude Volume Group stands in the center position of LVM.

3 How to

3.1 create PV

Use fdisk to create disk partitions with system id 8e which stands for Linux LVM.
In my case, I create a Physical Volume above my RAID-0 virtual disk partition /dev/md0p1.

# write lvm system id to md0p1 partition by fdisk tool
# sudo fdisk /dev/md0 
sudo pvcreate /dev/md0p1

3.2 create VG

sudo vgcreate foo /dev/md0p1

3.3 create LV

# create LV bar above the VG foo
sudo lvcreate -n bar -L 10g foo

format LV /dev/foo/bar with ext4 filesystem

sudo mkfs.ext4 /dev/foo/bar

resize /dev/foo/bar partition

sudo lvextend -L +10g foo/bar
sudo resize2fs /dev/foo/bar

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp