Linux Logical Volumes
From LinuxFanBoy
Logical Volume Management (LVM) does complicate the disk space management but it also provides some useful fetchers. LVM allows you to resize active partitions. LVM lets you create snapshot of a running file system that can be used for backups.
LVM starts with Physical Volumes (PV). These are made from physical disks (hda, hdb...) or physical disk partitions of type 0x8e (hda1, hda2, hdb1...). Think of these as just a bunch of blocks.
PVs are then combined to create Volume Groups (VG). You can add PVs to VGs to expand a disk.
The next step is to create Logical Volumes (LV). These create the /dev/volumegroup/logvol device that you can format into a file system.
The commands go like this:
Use fdisk to create physical partitions of type 0x8e - say hda3 and another on hdb2. The make these two partitions into physical volumes (PV).
pvcreate /dev/hda3 pvcreate /dev/hdb2
Next create a volume group (VG) of the two PVs you created
vgcreate newgroup /dev/hda3 /dev/hda2
Now create a logical volume (LV) 200M in size from the Volume Group you created
lvcreate -L 200M newgroup -n flex
Format it
mkexfs -j /dev/newgroup/lv0
and mount it.
mount /dev/newgroup/lv0 /home
labelfs \/home /dev/newgroup/lv0
And don't forget to mount this automaticly at boot time by editing /etc/fstab.
LABEL=/home /home ext3 defaults 1 2
To display the current LVM Volumes.
pvdisplay
Pratice Expanding nad schrinking LVM partitions. Don.t forget to do a ext2online after extending or reducing a LVM partition.
