RH135-7-LVM

###Logical Volume Management (LVM)###

Features:
 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:
  a. Volume Groups (VG)
   a1. Physical Volumes (PV) (/dev/sda2, /dev/sdb2, etc.)
  b. Logical Volumes (LV)
   b1. File system
 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)

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

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

 3. Create Volume Groups using 'vgcreate'
  a. 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
  a. lvcreate -L 10GB -n logvolvar1 volgroup001
  b. lvcreate -L 10GB -n logvolusr1 volgroup001
 5. Create File system on Logical Volume(s)
  a. 'mke2fs -j /dev/volgroup001/logvolvar1'
  b. 'mke2fs -j /dev/volgroup001/logvolusr1'
 6. Mount Logical Volume
  a. mkdir /var1
  b. 'mount /dev/volgroup001/logvolvar1 /var1
  c. mkdir /usr1
  d. '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:
  a. pvdisplay - physical volumes - represent raw LVM partitions
  b. vgdisplay - volume groups - aggregate physical volumes
  c. lvdisplay - logical volumes - file systems - mount here


Rename of Logical Volumes
 1. lvrename - used to rename volumes
  a. lvrename volume_group_name old new

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

Note: /dev/volgroup001/* is symlinks to /dev/mapper/

Remove Logical Volumes

Task: remove 'logvolusr1' from the logical volume pool
 a. umount /usr1
 b. lvremove /dev/mapper/volgroup001-logvolusr1
 c. use 'lvdisplay' to confirm removal


Resize Logical Volume:

Task: Grow (resize) 'logvolopt1' to 20GB
 a. lvresize -L 20GB /dev/volgroup001/logvolopt1
 b. lvdisplay - to confirm new size of logical volume
 c. df -h - will still reveal the current size
 d. Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
  d1. 'resize2fs -f -p /dev/volgroup001/logvolopt1'

Note: You may resize file systems online if the following are met:
 1. 2.6x kernel series
 2. MUST be formatted with ext3

Task: Shrink (resize) 'logvolopt1' to 15GB
 a. lvresize -L 15GB /dev/volgroup001/logvolopt1
 b. lvdisplay
 c. df -h
 d. 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

你可能感兴趣的:(linux,职场,lvm,休闲)