File System

To manage virtual groups you’ll need to install the lvm2 package.

sudo apt install lvm2

This enables you to manage the Linux file system as:

  • Physical Volumes (PVs) - physical disks
  • Volume Groups (VGs) - groups of physical volumes
  • Logical Volumes (LVs) - logical storage space like partitions created for usage by the operating system. They are formatted with file systems like ext4, xfs…

View a summary of these systems with:
pvs - physical volume summary
vgs - volume group summary
lvs - logical volume summary

Below disk_0 was manually created by me when I installed Debian. I created vg0 for use with Xen hypervisor.

$ sudo vgs
  VG     #PV #LV #SN Attr   VSize    VFree   
  disk_0   1   4   0 wz--n- <223.00g       0 
  vg0      1   0   0 wz--n- <223.00g <223.00g

To view these systems indepth, use the commands: pvdisplay, vgdisplay, lvdisplay

For example…

$ sudo vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <223.00 GiB
  PE Size               4.00 MiB
  Total PE              57087
  Alloc PE / Size       0 / 0   
  Free  PE / Size       57087 / <223.00 GiB
  VG UUID               2CaI43-NrOq-XaGe-GmKU-OR3z-vmcA-KBxP11
   
  --- Volume group ---
  VG Name               disk_0
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  21
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <223.00 GiB
  PE Size               4.00 MiB
  Total PE              57087
  Alloc PE / Size       57087 / <223.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               zkGGrS-P6TB-ENdw-I1iD-QwMM-f7x0-fCtsk4

Create Logical Volume

sudo lvcreate -n database-data -L 100G vg0
$ sudo lvs
  LV            VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  d0_lv0        disk_0 -wi-ao---- 284.00m                                                    
  d0_lv1        disk_0 -wi-ao----  19.07g                                                    
  d0_lv2        disk_0 -wi-ao----  47.68g                                                    
  d0_lv3        disk_0 -wi-a----- 155.96g                                                    
  database-data vg0    -wi-a----- 100.00g