Skip to content

            Lost ?  |  Need an account:
 
LVM Configuration PDF Print E-mail
(10 votes, average 4.30 out of 5)
Written by Tom Hirt   
Wednesday, 13 May 2009 10:24
Article Index
LVM Configuration
Physical Volume Creation
Volume Group Creation
Logical Volume Creation
Formatting a File System
Mounting a File System
All Pages

 

LVM Overview


LVM or Logical Volume Management is a tool used by Unix/Linux administrators to manage disk resources.  LVM provides a layer of abstraction between the underlying physical disk/volume and the host operating system (Unix administrators often refer to disks as volumes.)  LVM partitions can span across physical hard drives and can be re-sized (unlike traditional ext3 "raw" partitions.)  LVM partitions offers features such as resizing, snapshots and mirroring of volumes all of which can be very useful in a variety of situations for management of disk in the enterprise.

In this KB article, we'll show you how to configure LVM on a Linux system.  You can find additional articles in the Linux KB to guide you through other LVM administrative tasks such as renaming, removing, resizing, snapshots and mirroring.

Note: LVM is only supported in the Linux kernel 2.4 and above.  If you don't have support for LVM, you may have to recompile your kernel from source.

LVM Creation can be broken down into 7 steps:

  1. Partitioning
  2. Physical volume(s) creation
  3. Volume group(s) creation
  4. Logical volume(s) creation
  5. Formatting of the file system
  6. Mounting of file system
  7. Updating fstab for automatic volume mounting

 

Partitioning


LVM partitions must be of type 8e (Linux LVM.)  We are going to use fdisk to define three (3) new partitions on available disks installed in our server.

  1. Lets begin by taking a look at our current disks and their associated partitions (you must be root)

    [root@Linux01 ~]# fdisk -l

    Disk /dev/sda: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          13      104391   83  Linux
    /dev/sda2              14        1305    10377990   8e  Linux LVM

    Disk /dev/sdb: 4294 MB, 4294967296 bytes
    255 heads, 63 sectors/track, 522 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk /dev/sdb doesn't contain a valid partition table

    Disk /dev/sdc: 4294 MB, 4294967296 bytes
    255 heads, 63 sectors/track, 522 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk /dev/sdc doesn't contain a valid partition table

    Disk /dev/sdd: 4294 MB, 4294967296 bytes
    255 heads, 63 sectors/track, 522 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk /dev/sdd doesn't contain a valid partition table
    [root@Linux01 ~]#

    As you can see, we have one disk (/dev/sda) which already has a couple of partitions (for the running OS.)  We have highlighted the three available disks which we will use for our LVM file system (/dev/sdb, /dev/sdc/ and /dev/sdd).

  2. Define a new partition of type 8e (Linux LVM) on /dev/sdb using fdisk

    [root@Linux01 ~]# fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previous
    content won't be recoverable.

    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    Command (m for help): n
    Command action
    e   extended
    p   primary partition (1-4)
    p

    Partition number (1-4): 1
    First cylinder (1-522, default 1): 1
    Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): 522

  3. Change the type of the file system to 8e (Linux LVM)

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 8e
    Changed system type of partition 1 to 8e (Linux LVM)

    Command (m for help): p

    Disk /dev/sdb: 4294 MB, 4294967296 bytes
    255 heads, 63 sectors/track, 522 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         522     4192933+  8e  Linux LVM

  4. Write the changes to the partition table

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@Linux01 ~]#

  5. Repeat steps 2 - 4 until all the drives have partitions of type 8e created on them




Comments
Add New Search
Kartik Suryanarayanan  - Nice LVM artcile. |11/07/2009 04:56:00
HI,

It was a nicely written LVM configuration article. For me it was the part , where it was show how to change the PE size used for a VG.

Thanks a lot :-)

--Kartik S
thirt |15/07/2009 18:00:58
Hi Kartik,

Thanks for the feedback! Keep it coming. If you have any requests, post them in the forums area and we’ll get to them when we get sometime.

Regards,
Tom
Wojtek J |17/09/2009 08:08:30
Hello,
Same remark as my predecessor. The helpful info was PE size switch "-s".
However, the dark colour of the backgrouung is somehow painful ;-)
Wojtek
Anonymous |27/03/2011 23:20:58
plz give information about volume group and physical volumes
Ajay Sharma  - LINUX tutorial |27/03/2011 23:23:37
plz revert me through my mail
MD Shamim Akhtar  - Disk /dev/sdb doesn't contain a valid partition t |29/03/2011 01:39:35
Dear Sir,

I want to know what does it mean by this line, please make me understand.

"Disk /dev/sdb doesn't contain a valid partition table"

SAS |15/09/2011 01:47:31
It simply means that devices /dev/sdb, /dev/sdc and /dev/sdd don't have any partitions on them _yet_.
Partitions are added to the disks in steps 2 and forward.
Anonymous |02/05/2011 10:48:33
hi

Its good 8)
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry::evil::twisted::roll::wink::!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Tuesday, 02 June 2009 10:15
 

Forum Activity

Author:
Author: kenny22
Jan.24.12
Author: AaronRiley
Jan.15.12

Online Stats

Guests Online: 78
Members Online: 0