Thursday, December 31, 2009


1. Ability to create volume sets and stripe sets

2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)

3. LVM represents storage using a hierarchy:

• Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
• b. Logical Volumes
b1. File systems
4. LVM physical volumes can be of various sizes
5. Ability to resize volumes on the fly

Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)

6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
• fdisk /dev/sda, /dev/sdb, /dev/sdc
• n
• p
• +10G
• t - change to type '8e' (LVM)
• w
• partprobe /dev/sda

2. Create Physical Volumes using 'pvcreate'
• pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3

3. Create Volume Groups using 'vgcreate'

• vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3

Note: Volume groups can be segmented into multiple logical volumes

4. Create one or more Logical Volumes
• lvcreate -L 10GB -n logvolvar1 volgroup001
• b. lvcreate -L 10GB -n logvolusr1 volgroup001

5. Create File system on logical volume(s)
• mke2fs -j /dev/volgroup001/logvolvar1
• b. mke2fs -j /dev/volgroup001/logvolusr1

6. Mount logical volume
• mkdir /var1
• mount /dev/volgroup001/logvolvar1 /var1
• mkdir /usr1
• mount /dev/volgroup001/logvolusr1 /usr1

Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots

3-tiers of LVM display commands include:
• pvdisplay - physical volumes - represent raw LVM partitions
• vgdisplay - volume groups - aggregate physical volumes
• lvdisplay - logical volumes - file systems - mount here

Rename of Logical Volume:

1. lvrename volume_group_name old new - used to rename volumes

Rename 'logvolvar1' to 'logvolopt1'
• lvrename volgroup001 logvolvar1 logvolopt1

Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
• b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
• c. Update /etc/fstab

Remove Logical Volume:


Remove 'logvolusr1' from the logical volume pool

• umount /usr1
• lvremove /dev/mapper/volgroup001-logvolusr1
• use 'lvdisplay' to confirm removal

Resize Logical Volume:


Grow (resize) 'logvolopt1' to 20GB

• lvresize -L 20GB /dev/volgroup001/logvolopt1
• lvdisplay - to confirm new size of logical volume
• df -h - will still reveal the current size
• Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'
Note: You may resize file systems online if the following are met:
2.6x kernel series
MUST be formatted with ext3
Shrink (resize) 'logvolopt1' to 15GB

• lvresize -L 15GB /dev/volgroup001/logvolopt1
• lvdisplay
• df -h
• resize2fs -f -p /dev/volgroup001/logvolopt1

Note: online shrinking is not supported
• e. df -h
Note: Check disk utilization prior to shrinking to reduce the risk of losing data

LVM GUI utility:

• system-config-lvm

No comments:

Post a Comment