Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Wednesday, 30 August 2017

LVM (Logical Volume Manager) Concept on Linux RHEL / CentOS 5&6

L.V.M(Logical Volume Manager)



LVM is a method of allocating harddrive space into logical volumes that can be easily resized instead of partitions.
With LVM the harddrive (or) set of harddrives are allocated to one or more physical volumes.

The physical volumes are combined into volume groups
Each volume group is divided into logical volumes which are assigned mountpoints such as /home and filesystem types such as ext3


To configure LVM
1)Create three LVM partitions
2)Convert them as physical volumes
3)Create volume groups from physical volumes
4)Create logical volumes from volume groups and assign mountpoints

IMPLEMENTATION:
#fdisk /dev/sda
:n
+500M
:t

:8e    (Linux LVM)
:w   (save & exit)
#partx -a /dev/sda (update kernel)


To convert LVM partitions as physical volumes
#pvcreate /dev/sda
ex: pvcreate /dev/sda{9,10,11}

To view physical volumes
#pvdisplay

To create volume group
#vgcreate
ex: vgcreate bsrtech /dev/sda{9,10,11}

To view volume groups
#vgdisplay

To create a logical volume
#lvcreate -L <+size> -n
ex: lvcreate -L +300M /dev/bsrtech -n lv1

To view logical volumes
#lvdisplay

To format logical volumes
#mkfs.ext4 /dev/bsrtech/lv1

Create a mountpoint and mount logical volume on it
#mkdir /mysql
#mount  
/dev/bsrtech/lv1   /mysql
#cd /mysql
 

To extend size of logical volume 
#umount
#lvresize -L +
ex:lvresize -L +200M  
/dev/bsrtech/lv1
To make filesystem for extended size
#resize2fs
ex: resize2fs  
/dev/bsrtech/lv1
 #mount /dev/bsrtech/lv1  /mysql
 

To reduce a logical volume
note: whenever we are reducing an LVM we have to take backup (More Details #man lvreduce)
#mkdir  /lvm-bkp
#cp -rf /mysql/*  /lvm-bkp

#lvreduce -L <-size>
ex: lvreduce -L -100M  
/dev/bsrtech/lv1
 To format LVM
#mkfs.ext4
ex:mkfs.ext4 /dev/bsrtech/lv1

#mount 
/dev/bsrtech/lv1  /mysql
#cp -rf /lvm-bkp/* /mysql

To remove an LVM
#umount
#lvremove
ex:lvremove 
/dev/bsrtech/lv1

 To extend volume group
1)create another LVM partition
2)convert into physical volume

#vgextend
ex:vgextend /dev/bsrtech  /dev/sda12

To reduce volume group
#vgreduce
ex:vgreduce /dev/bsrtech  /dev/sda12


To remove volume group
#vgremove
ex:vgremove /dev/bsrtech

To delete physical volumes
#pvremove
ex:pvremove /dev/sda{9,10,11,12}

No comments:

Post a Comment