Packetwatch.net

LVM disk management commands in Red Hat Enterprise Linux



Last modified: Jun. 30, 2009

Contents
1 - Summary
2 - General information
3 - Physical volumes
4 - Volume groups
5 - Logical volumes


1 - Summary

This guide will show some LVM disk management commands in Red Hat Enterprise
Linux. LVM stands for logical volume manager. A logical volume provides storage
virtualization meaning that it allows you to create a logical storage volume
using multiple physical disks. This has been tested in Red Hat Enterprise Linux
5.


2 - General information

Find out what version of LVM is installed.
# rpm -qa | grep -i lvm
lvm2-2.02.40-6.el5
system-config-lvm-1.1.5-1.0.el5

Find out what hard disks the computer has and information about them.
# sudo /sbin/fdisk -l | grep Disk
Password: 
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
# sudo /sbin/hdparm -I /dev/sda | head -n 7 | tail -n 4
Password: 
ATA device, with non-removable media
        Model Number:       Hitachi HUA721010KLA330                 
        Serial Number:      GTF000PBGGTADF
        Firmware Revision:  GKAOA9N1
# sudo /sbin/hdparm -I /dev/sdb | head -n 7 | tail -n 4
Password: 
ATA device, with non-removable media
        Model Number:       Hitachi HUA721010KLA330                 
        Serial Number:      GTF000PBGGJSMF
        Firmware Revision:  GKAOA9N1

Display the local file system disk space usage.
# df -hl
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              93G   15G   75G  17% /
/dev/mapper/VolGroup00-LogVol00
                      1.7T  400G  1.2T  25% /data
tmpfs                 2.0G     0  2.0G   0% /dev/shm


3 - Physical volumes

Scan all disks for physical volumes.
# sudo /sbin/pvscan
Password: 
  PV /dev/sda3   VG VolGroup00   lvm2 [831.50 GB / 0    free]
  PV /dev/sdb1   VG VolGroup00   lvm2 [931.50 GB / 0    free]
  Total: 2 [1.72 TB] / in use: 2 [1.72 TB] / in no VG: 0 [0   ]

Display attributes of physical volumes.
# sudo /usr/sbin/pvdisplay /dev/sda3
Password: 
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               VolGroup00
  PV Size               831.51 GB / not usable 12.53 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              26608
  Free PE               0
  Allocated PE          26608
  PV UUID               wALAIn-1MfU-W1Zc-O70G-0194-2QS5-ddU4tT
   
# sudo /usr/sbin/pvdisplay /dev/sdb1
Password: 
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               VolGroup00
  PV Size               931.51 GB / not usable 11.19 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              29808
  Free PE               0
  Allocated PE          29808
  PV UUID               45HeHE-EJ0d-AK6A-KWWI-CUgL-4WAx-uXMWZn


4 - Volume groups

Scan all disks for volume groups.
# sudo /sbin/vgscan 
Password: 
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2

Display attributes of volume groups.
# sudo /usr/sbin/vgdisplay VolGroup00
Password: 
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.72 TB
  PE Size               32.00 MB
  Total PE              56416
  Alloc PE / Size       56416 / 1.72 TB
  Free  PE / Size       0 / 0   
  VG UUID               qTyO9u-1keX-a8b0-uAUa-VspH-tysg-Cte41M


5 - Logical volumes

Scan all disks for logical volumes.
# sudo /usr/sbin/lvscan
Password: 
  ACTIVE            '/dev/VolGroup00/LogVol00' [1.72 TB] inherit

Display attributes of logical volume
# sudo /usr/sbin/lvdisplay /dev/VolGroup00/LogVol00
Password: 
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                gNvKds-MZIH-ldaO-ghBA-Zk2S-8bUx-Cl9I7x
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.72 TB
  Current LE             56416
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


Last modified: Thu Jan 1 12:00:00 1970 NZST
Packetwatch Research 2002-2010.