• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

LVM Configuration : Logical Volume (LV) Operations/Utilities

by admin

Once you have created the Physical volumes and volume groups, the next step is to create logical volumes from the space allocated to volume groups. The post discusses few of the most commonly used logical volume related commands and utilities.

Creating Logical Volumes

Use the lvcreate command to create a new logical volume. This command automatically creates the block device nodes in the /dev directory. The syntax is:

# lvcreate [options] --size [size] --name LV_name VG_name

The –size option defines the size of the logical volume by allocating logical extents from the free physical extent pool of the volume group. For example, to create a logical volume named lv01 from the volume group named vg01 with a size of 2 GB, enter:

# lvcreate -v --size 2g --name lv01 vg01
    Archiving volume group "vg01" metadata (seqno 1).
    Creating logical volume lv01
    Creating volume group backup "/etc/lvm/backup/vg01" (seqno 2).
    Activating logical volume vg01/lv01.
    activation/volume_list configuration setting not defined: Checking only host tags for vg01/lv01.
    Creating vg01-lv01
    Loading vg01-lv01 table (253:2)
    Resuming vg01-lv01 (253:2)
    Wiping known signatures on logical volume "vg01/lv01"
    Initializing 4.00 KiB of logical volume "vg01/lv01" with value 0.
  Logical volume "lv01" created.

Displaying Logical Volumes

Use the lvdisplay command to display the attributes of logical volumes.

# lvdisplay vg01/lv01
  --- Logical volume ---
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                DyCyoq-5fF1-HujN-WeUi-XvYN-eloM-wdDSVt
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2017-10-02 13:28:01 +0530
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

In addition to lvdisplay, two other commands list information about logical volumes. The lvs command reports information about logical volumes in a more condensed form. The lvscan command scans all disks for logical volumes. Example:

# lvs
  LV   VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root cl   -wi-ao---- 17.00g                                                    
  swap cl   -wi-ao----  2.00g                                                    
  lv01 vg01 -wi-a-----  2.00g
# lvscan
  ACTIVE            '/dev/cl/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/cl/root' [17.00 GiB] inherit
  ACTIVE            '/dev/vg01/lv01' [2.00 GiB] inherit

Removing Logical Volumes
Use the lvremove command to remove a logical volume. You must include the volume group name as well as the logical volume name. You are prompted to confirm your request. Example:

# lvremove vg01/lv01
Do you really want to remove active logical volume vg01/lv01? [y/n]: y
  Logical volume "lv01" successfully removed

Additional LV Commands

The following commands are used to manipulate logical volumes :

  • lvchange : Change the attributes of logical volumes.
  • lvconvert : Change logical volume layout.
  • lvextend : Add space to a logical volume.
  • lvmdiskscan : List devices that may be used as physical volumes.
  • lvmsadc : Collect activity data.
  • lvmsar : Create activity report.
  • lvreduce : Reduce the size of a logical volume.
  • lvrename : Rename a logical volume.
  • lvresize : Resize a logical volume.
RedHat / CentOS : A beginners guide to LVM
LVM Configuration : Volume Group (VG) Operations/Utilities
LVM Configuration : Physical Volume (PV) Operations/Utilities

Filed Under: Linux

Some more articles you might also be interested in …

  1. apport-bug Command Examples in Linux
  2. Basic “chmod” Command examples in Linux
  3. CentOS / RHEL : How to block incoming and outgoing ports using iptables
  4. sed: command not found
  5. groupadd Command Examples in Linux
  6. “Failed to Synchronize Cache For Repo ‘repo_name’, Ignoring This Repo” – CentOS/RHEL 8 error
  7. The Ultimate Beginner’s Guide to Static Website Hosting With Google Firebase (for FREE)
  8. mpirun.openmpi: command not found
  9. po4a-updatepo Command Examples in Linux
  10. MySQL Server Error – “Can’t Create A New Thread (errno 11)”

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright