How to Create a Logical Volume Using LVM on Linux Systems

undefined

In this article, I’ll show you how to create a new logical volume within an existing LVM volume group. It’s a simple and straight froward task which you will face a lot when managing Linux Systems.

Prerequisites:

  • a working installation of LVM2, and
  • an existing LVM volume group with sufficient free space for the new logical volume.

Scenario

Suppose that the new logical volume to be 256 megabytes in size and named foo. Volume group vg0 has sufficient free space to accommodate it.

Method

Logical volumes are created using the lvcreate command:

# lvcreate --size 256M --name mimastech /dev/vg0

The volume will be accessible as either /dev/vg0/mimastech or /dev/mapper/vg0-mimastech. It may be used in much the same way as a hard drive partition.

Testing

Verify the existence of the logical volume using the lvdisplay command:

# lvdisplay /dev/vg0/mimastech

This should give a response of the form:

--- Logical volume ---
LV Name                /dev/vg0/mimastech
VG Name                vg0
LV UUID                afaHxF-nZrA-S1eo-kjsY-mt6C-p04e-IU8Bqu
LV Write Access        read/write
LV Status              available
# open                 0
LV Size                256.00 MB
Current LE             64
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:64

Next steps

Having created a new logical volume you may want to:

  • create a filesystem on it, or
  • use it as a swap device.

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

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

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