Monday, July 26, 2010

RHCE study notes:LVM Resizing

LVM Resizing in RHEL 5
1 Concept of LVM
a: Logical Volume Managment(LVM) is designed for system admin to easyily manage disk including add disks,replace disks, resize partition,backup by taking “sanpshots’.
b: LVM would manager disk through 3 layers including pv(physical volume),vg( volume group), and lv(logical valume)
c: pvcreate,vgcreate and lvcreate
d: 1PE=4MB; resize2fs for resizing ext2 & ext3 disk
2 Step by step
a: create LVM
step one:
#fdisk /dev/hda
step two:
#pvcreate /dev/hda{5,6,7}                        //create pv;5,6,7 indicate /dev/hda5, /dev/hda6, /dev/hda7
step three:
#vgcreate vgname /dev/hda{5,6,7}       //create vg
step four:
#lvcreate -L 1500M -n lvname vgname    //create lv; option -L/-l
step five:
# mkfs.ext3  /dev/vgname/lvname        //format lv for ext3
step six:
# mount /dev/gvname/lvname   /mnt/xxx  //mount LVM
b:Extend LVM
step one:
# vgdisplay /dev/vgname                    //checking for current PE
step two:
# lvextend  -l  +255  /dev/vgname/lvname  //list how many pe for extend LV; option -l
step three:
# resize2fs  /dev/vgname/lvname            //extend lv
step four
# df -h                                    //check result
c: reduce LVM
step one:
# umount /dev/vgname/lvname                //umount exsiting LVM for data security reason
step two:
# e2fsck -f /dev/vgname/lvname             //checking for disk info. (must done before resize)
step three
# resize2fs /dev/vgname/lvname 1024M       //reduce lvm to 1024M (not reduce 1024M)
step four
# lvreduce -L 1024M /dev/vgname/lvname     //reduce lvm
step five
# mount /dev/vgname/lvname /mnt/xxx        //mount new lvm and check PE info
# df -h