Thursday, November 22, 2012

LVM



Logical Volume Manager (LVM)
LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.With LVM, the hard drive or set of hard drives is allocated to one or more physical volumes. A physical volume can not span over more than one drive. 
The physical volumes are combined into logical volume groups, with the exception of the /boot/ partition. The /boot/ partition can not be on a logical volume group because the boot loader can not read it. If the root / partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.
Since a physical volume can not span over more than one drive, to span over more than one drive, create one or more physical volumes per drive. 



The logical volume group is divided into logical volumes, which are assigned mount points such as /home and / and file system types such as ext3. When "partitions" reach their full capacity, free space from the logical volume group can be added to the logical volume to increase the size of the partition. When a new hard drive is added to the system, it can be added to the logical volume group, and the logical volumes that are the partitions can be expanded.

Some of useful commands in LVM creation
1.      pvcreate is used to create physical volume group
2.      vgcreate is used to create volume group
3.      lvcreate is used to create logical volume
4.      lvresize is used to resize the the logical volume
5.      resize2fs is used to update the resized volume
6.      vgextend is used to extend the size of volume group
Example to create LVM
To accomplish this task you must be login form root account. So first login from root and verify your hard disk status with fdisk –l command ( This command will show that where your hard disk is mounted. You should use the mount point which show in the output of this command. For example if you see /dev/hda then you should use fdisk /dev/hda in next command. Or if you see /dev/sdb then you should use fdisk /dev/sdb in next command.
 [root@raju]#fdisk /dev/sda
  command(mfor help):n
  command(mfor help):e
First cylinder ("36495-38913", default 36495):
Using default value 36495
Last cylinder, +cylinders or +size{K,M,G} ("3649538913", default 38913): +100M
 Command (m for help):t
 Command (m for help): 8e
 Command (m for help): w
[root@raju]#Partx -a  /dev/sda
[root@raju]#pvcreate /dev/sda5
[root@raju]#vgcreate  -s 25M Cisco /dev/sda4  #creates volume group named Cisco
[root@raju]#lvcreate   - l 4 –n CCNA Cisco #creates 4 extends of volume group 25mb

   [root@raju]#mkfs.ext4 /dev/mapper/Cisco
   [root@raju]#mkdir /raju
   [root@raju]#vi /etc/fstab
   /dev/Cisco/CCNA  /raju  ext4     defaults  0 0



Stay Connected With Free Updates!

Subscribe via Email

Follow me!

Leave Your Comment Below If You Like This Post

0 comments: