Helpdesk Support

Official Supportmonk Company Blog!

LVM [Logical Volume Management]

March 10, 2013 , 11:32 am

LVM is an advanced technology, which provides a higher level management of storage volumes. It increases the performance & availability of Linux systems. LVM provides a higher level view of storage devices than that of traditional hard disks & partitions. LVM also enables management of storage devices in user defined groups. ie. It allows us to name the hard-disk/partitions with meaningful names like “Tech”, “Soft” … rather than using traditional hard disk names such as ‘/dev/sda’ & ‘/dev/sdb’.

Advantages OF LVM

1). Enhances Uptime

Storage volumes created under LVM can be moved & resized without any down time. This is possible because, LVM hides the details of where on which hard disk the actual data is stored for a particular application from the entire system. Applications will be using the logical volumes created in LVM. Since LVM hides the hardware details from applications, it completely isolates hardware & software. So it is possible to make changes in hardware  without the software noticing about it, all during run time. This is increases the uptimes, because you don’t need to stop any applications for making changes in the hardware.

2). Abstract scattered Physical Disks & Partitions to form a single storage device.

Is it possible to create a partition that sizes 100Gb, from two 50Gb partitions?. In traditional method of disk management is it not possible to create a partition which sizes more than that of the largest disk available. However with LVM it is possible. You can add the two 50Gb hard disks in to a LVM Volume Group, and create a 100Gb partition.

3). Add more hard disks to LVM disk pool &  extent the partitons online.
4). Perform consistent backup using snap shots.

Structure Of LVM

LVM has three major elements.

1). Volumes – Physical & Logical Volumes, Volume Groups.
2). Extents – Physical & Logical extents.
3). Device mapper – Kernel module for LVM.

A Physical Volume(PV) are physical hard disks or hard disk partitions (Lvm equivalent of /dev/sdb or /dev/sdb). A Volume Group(VG) is an aggregate of Physical Volumes. A VG can be partitioned into Logical Volumes (LV). The following figure explains the structure of LVM.

Physical Disk(PD) 0                        PD1            PD2
—————————————   ————  ————
PVs    | /dev/sda1 |  /dev/sda2 | /dev/sda3  |   | /dev/sdb |  | /dev/sdc |
—————————————   ————  ————
↓          ↓            ↓    VG0           ↓             ↓
VGs    |           |            |            |                 |          |                                                   +
LVs    |                LV0                          |  Free Space        |

| /data |

In the above example all 3 partitions in PD0, the whole of PD2 & PD3 were added as PVs to Volume Group 0 (VG0). The VG is the layer which maps the PVs to LVs. VG is the hard disk equivalent of LVM. Once you add the PVs to VG, you can create LVs of any size, to the maximum of VG size. In the above example we have created a LV , LV0 keeping some free space for future expansion. For all practical purposes LVs are LVM equivalent of Physical Disk Partitions. Once you create the LVs, you can format it with any file-system you wish to use(ext3, fat32 ..), mount it under a directory and start using it. In the above example we have mounted LVO under /data.


For a LVM to map a PV to LV, both the LVs & PVs must have the same quantum size for their basic blocks. These are called Physical Extents (PEs) & Logical Extents (LEs). The dafault extent size is 4MB. PE refers to the granularity of a LVM. ie if you choose an extent size of 10Mb, you can only shrink/extent LVs in steps of 10Mb.

PV   | PE | PE | PE | PE | PE | PE | PE | PE | PE | PE | PE|

LV   | LE | LE | LE | LE | LE | LE | LE | LE | LE | LE | LE|

Device Mapper (dm_mod)

dm_mod , Device Mapper is a Linux kernel module whose function is to map devices. This kernael module is required by LVM. You need to enable it, if it not already loaded in your system. This can be done using the modprobe command as given below.

# modprobe dm_mod

When creating LVs & VGs you can give them meaning full names. It is the device mapper who map these names correctly to the underlying Physical Devices.

Device File Naming Convention

Assume that you have created a VG VG0 & a LV LV0 inside it. Then the device mapper (dm_mod) will following device files in /dev directory.

* /dev/mapper/VG0-LV0
* /dev/VG0/LV0

General device file naming format for an LVM is

/dev/[VG-name]/[LV-name]  –> /dev/mapper/[VG-name]-[LV-name]

Where /dev/[VG-name]/[LV-name] is a soft link to /dev/mapper/[VG-name]-[LV-name] . You can use these device names for mounting and unmounting a LV.

eg: mount /dev/VG0/LV0 /mnt , mounts Volume Group VG0 to /mnt.

Create A Logical Volume & Mount it.

Step 1).

Make sure that LVM is installed on your system.

# rpm -qa | grep -i lvm



Step 2).

make sure that dm_mod mapper module is loaded

# lsmod | grep dm_mod


dm_mod  63225    7    dm_mirror,dm_multipath,dm_raid45,dm_log

If it is not loaded at boot time enable it using modprobe command

# modprobe dm_mod

step 3).

Create Physical Volumes. We are going to create PVs using /dev/sda1, /dev/sda2, /dev/sda3. You can use ‘pvcreate’ command for creating PVs.

# pvcreate /dev/sda1 /dev/sda2 /dev/sda3

Physical voulme “/dev/sda1′ successfully created.
Physical voulme “/dev/sda2′ successfully created.
Physical voulme “/dev/sda3′ successfully created.


* You can use ‘pvs or pvscan’ command to list the available physical volumes on a system.
* It is recommended to mark the Physical Volume partitons as ‘Linux LVM, partition ID ox8e’ in partiton table. This can be done using fdisk command.

step 4).

Create a VG ‘Software’ using these PVs. You can use the ‘vgcreate’ command to create VGs.

# vgcreate Software /dev/sda1 /dev/sda2 /dev/sda3

Volume group “Software” successfully created.


* You can use ‘vgs’ command to list available Logical Volumes on your system.

Step 5).

Make a new logical volume called ‘java’ in the volume group “Software”. You can use ‘lvcreate’command to create a LV.

# lvcreate -L 1000M -n java Software


Logical voulme “java” created.

It creates a LV of size 1000M.


* You can use the command ‘lvs’ to list available logical volumes on your system.

step 6).

Create a filesystem ‘reiserfs’ in the newly created LV ‘java’.

# mkfs.reiserfs /dev/Software/java

The above command will format the logical volume ‘java’ with ‘reiserfs’ filesystem.

step 7).

Mount it under /Software directory.

# mkdir /Software
# mount -t reiserfs /dev/Software/java /Software

Now you can access data located in LV ‘java’ by accessing the directory ‘/Software’.

Extending Logical Volumes

If you have enough free space in a LV, you can just use the ‘lvextend’ command inorder to extend a logical volume.
There is no need to unmount the LV.

# lvextend -L 2G /dev/Spftware/java

Extending logical volume ‘java’ to 2GB
Logical volume successfully resized.

The above command extend the logical volume ‘java’ to the size of 2Gb.

After extending the logical volume, you need to also extend the file-system to use the extra space.

# resize_reiserfs /dev/Software/java

If you don’t have enough free space left on your Volume Group for extending LV, you need to add more PVs to your VG.高級ブラック鏡面?120cm幅 2段チェスト+大型3段チェスト付き 鏡面パソコンデスク3点セット 幅120×奥行60 オフィスデスク パソコンデスク pcデスク UV塗装 【代引き不可】
レンジ台 完成品 レンジボード 大型 大型レンジ対応 キッチンカウンター 120 幅90 80 90 電子レンジ台 レンジ ラック キッチンラック キッチンカウンター 伸縮 コンセント付き作業台 コー
バーチェ W200幅 ウォールナット材 無垢材 + 突き板 完成品 テレビボード テレビ台 AVボード プレミアム/学割対象店 ■ kn_p x10
ファイントラック(finetrack) ポリゴン4フーディ Men’s S TA(タイガ) FIM0221
エレクター スタンダードエレクターシェルフ S610/S1830 5段 L600031
【ポイント20倍】(業務用200セット) ジョインテックス OAタップ 台形型 A737J
[送料無料]ペアリング 結婚指輪 マリッジリング ダイヤモンド ブルーダイヤモンド プラチナ 2本セット【楽ギフ_包装】0824カード分割【コンビニ受取対応商品】
《送料無料》 杉工場 学習デスク 国産品 【アクシス2】100幅セット(デスク+本棚+リフティングワゴン) アルダー材 格安家具通販
●ポイント10倍 8/26 10時からエントリー&カード決済● コーナーソファー コーナーソファ セットフロアコーナーソファーセット (Furise/フリーゼ) ハイタイプ (カウチソファ コーナーソ
ピエール=オーギュスト?ルノワール アンブロワーズ?ヴォラール F30サイズ F30号 910x727mm ※個人宛配送?代引不可※ 額縁付絵画 インテリア 額入り 壁掛け 油絵 ピエール=オーギ

Outsourced Customer Support