A brief about LVM

source: http://www.snow.nl/dist/xhtmlc/ch04s03.html#id2549161

Configuring Logical Volume Management

lvm is a logical volume manager for Linux. It enables you to concatenate several physical volumes (hard disks etc.) to a so-called volume groups, forming a storage pool, much like a virtual disk. IDE, SCSI disks, as well as, multiple devices (MD) are supported.

In the ASCII art below, the concepts/terminology used by lvm are sketched. On the right side the names of the commands are shown that can be used to manipulate/create the layer sketched on the left.

Figure 4.1. LVM concepts in ASCII art

+----------------[ Volume Group ]-------------------+
|                                                   |
| +-----------------------------------------------+ |
| | filesystem        | filesystem                | |    mkfs
| +-------------------+---------------------------+ |
| | logical volume    | logical volume            | |    lvcreate
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| | | | | | | | |physical extends | | | | | | | | | |    vgcreate
  | physical volume   |               |           |      pvcreate
  | partition         |               |           |      fdisk (0x8e)
The physical media / partitions
a hard disk, or a partition, e.g. /dev/hda, /dev/hda6 or /dev/sda. You should set the partition types of the disk or partition to 0x8e, which is “Linux LVM”. Partitioning is done using fdisk. Please note that your version of fdisk may not yet know this type, so it will be listed as “Unknown”. You can turn any consecutive number of blocks on a block device into a Physical Volume:

Physical Volume (PV)
a physical medium with some administrative data added to it. The command pvcreate can be used to add the administration onto the physical medium. The command vgcreate is used to create a volume group, which consists of one or more PV’s. A PV that has been grouped in a volume group contains Physical Extents:

Physical Extents (PE)
Physical Extents are blocks of diskspace, often several megabytes in size. Using the command lvcreate you can assign PEs to a Logical Volume:

Logical Volume (LV)
A Logical Volume. On a logical volume we can use the command mkfs to get a Filesystem:

ext2, ReiserFS, NWFS, XFS, JFX, NTFS etc. To the linux kernel, there is no difference between a regular partition and a Logical Volume. A simple mount suffices to be able to use your logical volume.

Some examples of typical usage of the LVM commandset follow. Initially, you need to set the partition type for the partitions to use to create logical volumes to 0x8e. Let’s assume we have partitions /dev/hda4 and /dev/hda5, and they are set to the correct partitioning type. To create a physical volume on both partitions (i.e. to set up the volume group descriptor) you type (being the superuser):

# pvcreate /dev/hda4 /dev/hda5

Now we have created two physical volumes. Next, we will create a volume group. A volume group needs to have a name (we choose volume01). To create our volume group, using our previously defined physical volumes, type:

# vgcreate volume01 /dev/hda5 /dev/hda4

The previous command line is the most basic form (refer to the manual pages for a list of configurable parameters). This will create an array of physical extents, by default they are 4 Mb in size. Using these extents we can create one or more logical volumes, e.g:

# lvcreate -L 100M volume01

.. this creates a logical volume with a default name choosen by lvcreate and starts with the string lvol followed by a digit — let’s assume lvol0. The logical volume will be created using the volumegroup volume01. The name of the devicefile for this volume will be /dev/volume01/lvol0. Next, we can make a filesystem on the volumegroup, as usual, using mkfs, e.g. an xfs filesystem:

# mkfs -txfs /dev/volgroup/volname

The resulting filesystem can be mounted as usual:

# mount /dev/volgroup/volname /mnt

One of the nicest features of LVM is the possibility of taking snapshots of volumes. A snapshot is a virtual copy of the volume to enable easy backups. Another interesting feature is striping, which can result in better performance, but also in a higher risk of losing your data.

3 Responses to “A brief about LVM”

  1. Pravin Says:

    Try this url, helped me a lot

  2. vijaypravin Says:

    Thanks for sharing..!! I love your post .. I am looking more post like this one on this blog .. this post proves really helpful for me .


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: