• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Disk management

LVM commands tutorial: Part 3: Logical Volume (lvcreate, lvdisplay, lvremove)

Published: November 18, 2016 | Modified: June 20, 2020



Series of the tutorial to learn LVM commands. In this part, learn how to create, delete the logical volume and view details of it (lvcreate, lvdisplay, lvremove)

This is the last part of the LVM commands tutorial. Previously we have seen physical volume, volume group commands which can be seen on below links :

  • Part 1 : Physical Volume (pvcreate, pvdisplay)
  • Part 1 : Physical Volume (pvchange, pvmove)
  • Part 2 : Volume group (vgcreate, vgdisplay, vgscan)
  • Part 2 : Volume group (vgextend, vgreduce, vgexport, vgimport)
  • Part 2 : Volume group (vgcfgbackup, vgcfgrestore, vgchange)
  • Part 2 : Volume group (vgremove, vgsync)
  • Part 3 : Logical Volume (lvcreate, lvdisplay, lvremove)
  • Part 3 : Logical Volume (lvextend, lvreduce, lvchange)
  • Part 3 : Logical Volume (lvsync, lvlnboot)

Logical volumes are small slices carved out of physical volumes storage space which is collectively available in the volume group. For more details check LVM legends.

Command: lvcreate

This command used to create a new logical volume. Logical volumes are mounted on directories as a mount point. So logical volume size is the size you want for the mount point. Use a command like below :

# lvcreate -L 1024 /dev/vg01
Logical volume "/dev/vg01/lvol1" has been successfully created with character device "/dev/vg01/rlvol1"
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

In the above command, you need to supply size in MB (1 GB in the above example) to -L argument and volume group name in which you need to create that LV. If no name suggested in command then by default command creates LV with name /dev/vg01/lvolX (X is next available number).

This command supports below options –

  • -l Number of LEs
  • -n LV Name

Created LV details can be seen using command lvdisplay.

Command: lvdisplay

We have seen above how to create LV, now we will see how to view details of it. This command is the same as pvdisplay for PV and vgdisplay for VG. It shows you details like name, volume group it belongs to, size, permission, status, allocation policy, etc.

# lvdisplay /dev/vg01/lvol1
--- Logical volumes ---
LV Name                     /dev/vg01/lvol1
VG Name                     /dev/vg01
LV Permission               read/write
LV Status                   available/syncd
Mirror copies               0
Consistency Recovery        MWC
Schedule                    parallel
LV Size (Mbytes)            1024
Current LE                  32
Allocated PE                32
Stripes                     0
Stripe Size (Kbytes)        0
Bad block                   on
Allocation                  strict
IO Timeout (Seconds)        default

More detailed output can be obtained with -v option. In this detailed output, you can get the LE details where they reside and LV distribution across disks.

# lvdisplay -v /dev/vg01/lvol1
--- Logical volumes ---
LV Name                     /dev/vg01/lvol1
VG Name                     /dev/vg01

----- Output clipped ----

   --- Distribution of logical volume ---
   PV Name                 LE on PV  PE on PV
   /dev/disk/disk22        32        32

   --- Logical extents ---
   LE    PV1                     PE1   Status 1
   00000 /dev/disk/disk22        00000 current
   00001 /dev/disk/disk22        00001 current
   00002 /dev/disk/disk22        00002 current
   00003 /dev/disk/disk22        00003 current
   00004 /dev/disk/disk22        00004 current
   00005 /dev/disk/disk22        00005 current
   00006 /dev/disk/disk22        00006 current
   00007 /dev/disk/disk22        00007 current
   00008 /dev/disk/disk22        00008 current
   00009 /dev/disk/disk22        00009 current
   00010 /dev/disk/disk22        00010 current
   00011 /dev/disk/disk22        00011 current
   00012 /dev/disk/disk22        00012 current
   00013 /dev/disk/disk22        00013 current
   00014 /dev/disk/disk22        00014 current

----- output truncated -----

Command: lvremove

Removing a logical volume is data destroying task. Make sure you take the backup of data within the mount point then empty it and stop all user/app access to it. If LV is not empty then the command will prompt you for confirmation to proceed. 

# lvremove /dev/vg01/lvol1
The logical volume "/dev/vg01/lvol1" is not empty;
do you really want to delete the logical volume (y/n) : y
Logical volume "/dev/vg01/lvol1" has been successfully removed.
Volume Group configuration for /dev/vg03 has been saved in /etc/lvmconf/vg01.conf

Once lvol is deleted its number is again available for next new lvol which is being created in the same VG. All PE assigned to this LV will be released as free PE and hence free space in VG will increase.

We will be seeing how to extend and reduce LV also how to activate or deactivate LV in the next post.

⇠ Previous article
LVM commands tutorial: Part 2: Volume group (vgremove, vgsync)
Next article ⇢
LVM commands tutorial: Part 3: Logical Volume (lvextend, lvreduce, lvchange)

Related stuff:

  • Run levels in HPUX at a glance
  • How to do safe and graceful Measureware service restart in HPUX
  • Understanding /etc/hosts file
  • UID range in hpux
  • How to mount ISO file in Linux?
  • Basics of LVM legends
  • How to restart NFS in HPUX
  • LVM cheatsheet
  • HP blade firmware upgrade process HPUX
  • How to rename logical volume in Linux and HPUX
  • Auto port aggregation APA configuration in HPUX
  • How to remove password expiry in HPUX HP Unix

Filed Under: Disk management, HPUX Tagged With: how to create logical volume, how to delete logical volume, linux logical volume, logical volume management, lvcreate command, lvdisplay command, lvremove command, view details of logical volume, what is a logical volume

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

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

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.