Notes and Commands for LVM (Linux Volume Manager)

Below are some raw notes I took while reading about Logical Volume Managers. I wont go into detail, but helper notes are next to each command. LVM is awesome, I’ve discovered.

It allows you to do things like take two USB devices, and pool them together in one Volume Group, in turn, making those two devices into one partition that’s mountable.

Also, you can extend the Logical Volumes and resize them, without rebooting. I encourage you to do more independent reading on the issue, but here are my raw notes.

LOGICAL VOLUME MANAGER

- LVM consists of different components
  -> Physical Volumes: Unused partions on hard disks
  -> Volume Groups: Contain one or more Physical Volumes
  -> Logical Volumes: Usable volumes created by LVM

# pvcreate /dev/sdc <-- allows lvm to use partition
# pvdisplay <-- shows details about each PV


* PE (Physical Extent): Block size must chosed before creating Volume Group

# vgcreate vg00 /dev/sdc/ /dev/sdb <-- creates volume group named vg00 out of partition
# vgcreate vg00 -s 		   <-- changes PE size, used for the size of written blocks
# vgdisplay 			   <-- details about volume groups

# lvcreate -L 15GB -n data vg00    <-- creates logicalvolume 15GB named 'data' on volumegroup vg00
# lvcreate -L 10GB -n extra vg00   <-- creates logicalvolume 10GB named 'extras' on volumegroup vg00
# lvdisplay 	                   <-- shows Logical Volume display

Useful commands:
# lvscan, pvscan, and vgscan
# vgextend <-- increases volume group size
# lvextend <-- increases logical volume size

Removing Logical Volumes
# lvremove /dev/vg00/extras <-- remove logical volume
# lvremove /dev/vg00/	    <-- remove logical volume
# vgremove /vg00	    <-- removes volume group named vg00
# pvremove /dev/sdc	    <-- removes phyiscal volume


Adding size to Logical Volume
* Make new physical volume
# pvcreate /dev/sdc
! creates new physical volume on /dev/sdc

# vgextend group_name /dev/sdc
! adds new physical device to volume group names 'group_name'
# lvcreate -L 10GB -n new_vol_name VG_X
! creates new logical volume of 10gb, named 'new_vol_name' on volume group named 'VG_X'
------------------------------------------------------------

 

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *