Understanding LVM

LVM terminology:
a. Physical Volume (PV) : A PV is nothing more than a physical medium with some administrative data added to it - once you have added this, LVM will recognise it .
b. Physical Extents (PE) :- Physical Extents are like really big blocks, often with a size of megabytes.
c. Volume Group (VG) - A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it's more accurate to say that it contains PEs which are provided by these hard drives.
d. Logical Volumes (LV) - A logical volume functions like a normal partition -- it have a filesystem such as Ext3, and a mount point. From , Volume Group, PEs can be assigned to a logical Volume (LV).

Creating Physical volumes:
#pvcreate /dev/sda3

Multiple physical volumes
#pvcreate /dev/sda9 /dev/sda10


Creating a volume group:
#vgcreate home2 /dev/sda3

Multiple physical volumes to make up a volume group
#vgcreate home3 /dev/sda9 /dev/sda10

Creating logical volume:
#lvcreate --size 1G -n downloads home2
now,
#mkfs.ext3 /dev/home2/downloads
#mkdir /home/downloads
#mount -t ext3 /dev/home2/downloads /home/downloads
Add a line to the /etc/fstab file
/dev/home2/downloads /home/downloads ext3 defaults 1 2

Resizing logical volumes:
#umount /home/downloads
#lvextend -L +1G /dev/home2/downloads
#resize2fs /dev/home2/downloads

Similar to the lvextend there is the lvreduce command:
#lvreduce -L -500M /dev/home2/downloads
#resize2fs /dev/home2/downloads

Modifying volume groups:
a. unmount the logical volumes within your volume group.
b. #vgextend home2 /dev/sda5 /dev/sda7
(The volume group home2 is now made up of sda3, sda5, and sda7)

Remove a volume group
a. Unmount your logical volume
b. #vgremove home2

A Physical Volume, containing Physical Extents:

+-----[ Physical Volume ]------+
| PE | PE | PE | PE | PE | PE |
+------------------------------+

A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:

+------[ Volume Group ]-----------------+
| +--[PV]--------+ +--[PV]---------+ |
| | PE | PE | PE | | PE | PE | PE | |
| +--------------+ +---------------+ |
+---------------------------------------+

We now further expand this:

+------[ Volume Group ]-----------------+
| +--[PV]--------+ +--[PV]---------+ |
| | PE | PE | PE | | PE | PE | PE | |
| +--+---+---+---+ +-+----+----+---+ |
| | | | +-----/ | | |
| | | | | | | |
| +-+---+---+-+ +----+----+--+ |
| | Logical | | Logical | |
| | Volume | | Volume | |
| | | | | |
| | /home | | /var | |
| +-----------+ +------------+ |
+---------------------------------------+


You can use the lvdisplay command see logical vloume's status.

http://www.ibm.com/developerworks/library/l-lvm2/index.html

http://www.linux.com/feature/11864

Comments

Ravi Shankar said…
shai hai guru lage raho .......

Popular posts from this blog

How do I Use the Linux Top Command?

IOPS measurement