Setup Flexible Disk Storage with Logical Volume Management (LVM) in Linux – PART 1

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Babin Lonston

I'm Working as a System Administrator for last 10 year's with 4 years experience with Linux Distributions, fall in love with text based operating systems.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

23 Responses

  1. Harivansh says:

    How to check how much space is utilize via LV in Sectors and tracks ?
    if am removing volume from vg there output is /dev/vdb2 is Still in use ?

  2. mohammad says:

    hello.
    In No 10 you told that :
    “List and see how much free spaces are there to create logical volumes using pvs command”
    But its picture is output of vga command

    please correct the sentens and picture.

    Thank you.

  3. Nazri says:

    Thank you very much for the details. Now it’s easy for me to understand LVM concept.

  4. Umesh says:

    Very Good… Keep it UP

  5. Dmitry says:

    Hi

    Please tell – should I use system-storage-manager (ssm) for Centos 7?

    Thank you

  6. Mario says:

    Hi Babin,

    good post.
    I have some doubts when trying to repeat your steps. I’m playing with oVirt 3.4 Glusterized, and CentOS 6.5 .
    In my two physical hosts, added a new FC LUN with 200 GB.

    How do I use it?
    How do I configure multipath? I see two paths to the same LUN.

    [root @ CentOS-H1 ~] # lsscsi
    [0: 0: 0: 0] disk HP LOGICAL VOLUME 3.55 / dev / sda
    [0: 1: 0: 0] B320i storage HP 3:55 –
    [5: 0: 0: 0] cd / dvd hp DVDRAM GT80N EA02 / dev / sr0
    [7: 0: 0: 0] disk VRAID 0533 DGC / dev / sdb
    [7: 0: 1: 0] disk VRAID 0533 DGC / dev / sdd
    [8: 0: 0: 0] disk HP iLO LUN 0 2:09 00 Media / dev / sdc

    [root @ CentOS-H1 ~] # multipath -ll
    36006016043a036009f784f47cf0ce411 dm-2 DGC, VRAID
    size = 200G features = ‘1 queue_if_no_path’ hwhandler = “1 emc ‘wp = rw
    | – + – Policy = “round-robin 0 ‘prio = 1 status = active
    | `- 7: 0: 1: 0 sdd 8:48 ready active running
    `- + – Policy =” round-robin 0 ‘prio = 0 status = enabled
       `- 7: 0: 0: 0 SDB enable ready running 8:16

    [[email protected] ~]# pvs
    PV VG Fmt Attr PSize PFree
    /dev/mapper/36006016043a036009f784f47cf0ce411p1 lvm2 a– 200.00g 200.00g
    /dev/sda2 vg_centosh1 lvm2 a– 558.24g 0

    I’m not a Linux guy, but wanted to test the oVirt 3.4, Glusterized.

    Can you give me some tips please?

    Thanks in advance.

    • good post.

      // Thanks buddy //

      I have some doubts when trying to repeat your steps. I’m playing with oVirt 3.4 Glusterized, and CentOS 6.5 .
      In my two physical hosts, added a new FC LUN with 200 GB.

      How do I use it?
      How do I configure multipath? I see two paths to the same LUN.

      // If you get the LUN in two paths mean already picked by multipath. If you need to assign a alias you can edit the file under /etc/multipath.conf and give a alias find the LUN id under /dev/disks/by-id/ then give the LUN id in multipath.conf. Even we can change the permission to some other users. //

      [root @ CentOS-H1 ~] # lsscsi
      [0: 0: 0: 0] disk HP LOGICAL VOLUME 3.55 / dev / sda
      [0: 1: 0: 0] B320i storage HP 3:55 –
      [5: 0: 0: 0] cd / dvd hp DVDRAM GT80N EA02 / dev / sr0
      [7: 0: 0: 0] disk VRAID 0533 DGC / dev / sdb
      [7: 0: 1: 0] disk VRAID 0533 DGC / dev / sdd
      [8: 0: 0: 0] disk HP iLO LUN 0 2:09 00 Media / dev / sdc

      [root @ CentOS-H1 ~] # multipath -ll
      36006016043a036009f784f47cf0ce411 dm-2 DGC, VRAID
      size = 200G features = ‘1 queue_if_no_path’ hwhandler = “1 emc ‘wp = rw
      | – + – Policy = “round-robin 0 ‘prio = 1 status = active
      | `- 7: 0: 1: 0 sdd 8:48 ready active running
      `- + – Policy =” round-robin 0 ‘prio = 0 status = enabled
      `- 7: 0: 0: 0 SDB enable ready running 8:16
      // babin 36006016043a036009f784f47cf0ce411 dm-2 DGC, VRAID // In this line you will get the alias which you have assigned in multipath.conf

      // dm-2 // this is the device we going to format and create a mount point

      Then to create a mount point we need to do the below steps.

      # pvcreate /dev/mapper/dm-2
      # vgcreate volgrp /dev/mapper/dm-2
      # lvcreate -L +200G -n logvol01 /dev/mapper/dm-2

      then format it and mount it under any mount point

      # mkfs.ext4 /dev/mapper/volgrp-logvol01

      mount it

      # mount /dev/mapper/volgrp-logvol01 /mnt/babin

      //

      [[email protected] ~]# pvs
      PV VG Fmt Attr PSize PFree
      /dev/mapper/36006016043a036009f784f47cf0ce411p1 lvm2 a– 200.00g 200.00g
      /dev/sda2 vg_centosh1 lvm2 a– 558.24g 0

      Above step is fine but not using a alias and it will get confuse once you have more storage disks in same machine.

      //

      Welcome..

  7. JuanSys76 says:

    excelente….

  8. Welcome bro, sorry for the typo will clear ..

  9. Oliver says:

    Hi,

    nice article, heres a little addition:

    You want to use option “-c” of fdisk to make sure that there is a correct alignment (dividable with 2), without this option your partition starts at 63 which leads to a misaligned disk and reduced performance.

    Greetings
    Oliver

  10. Medhansh says:

    HI,

    Article is good except some typos.

    Keep posting such a good article.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.