Creating / Resizing Logical Volume

Logical Volume Manager is a high level layer that allows great flexibility in to resize or move between physical devices easily.  Below are the summary steps to create volume group (Appsvg), logical volume (AppsOracle), and file system (Apps):

1)  Create physical partitions

 fdisk is used to create 2 partitions  /dev/sdi1 and /dev/sdi2. 

                Device Boot      Start         End      Blocks   Id  System
/dev/sdi1               1        1946    15631213+  8e  Linux LVM
/dev/sdi2            1947        3892    15631245   8e  Linux LVM

pvcreate /dev/sdi1
 Physical volume "/dev/sdi1" successfully created
pvcreate /dev/sdi2
 Physical volume "/dev/sdi2" successfully created

2)  Assign physical partitions to a volume group Appsvg

vgcreate Appsvg /dev/sdi1 /dev/sdi2
 Volume group "Appsvg" successfully created

3)  Create logical volume from volume group

lvcreate –L  16GB Appsvg –n AppsOracle
 mkfs.ext3 /dev/Appsvg/AppsOracle
mkdir /apps
mount /dev/Appsvg/AppsOracle /apps/

4)  Add the entry in /etc/fstab
vim /etc/fstab
/dev/Appsvg/AppsOracle  /apps                   ext3    defaults        1 2


5)  Check volume group, logical volume via commands like vgs, vgdisplay, lvs, lvdisplay , etc..for its characteristic
 
To extend logical volume and file systems, follow these steps:

Add new physical partition (/dev/sdi3, etc.):  vgextend Appsvg /dev/sdi3

Extend logical volume:  lvextend –L  17G /dev/Appsvg/AppsOracle

Resize the file system:  resize2fs /dev/Appsvg/AppsOracle

No comments:

Post a Comment