Docstoc

lvm in linux

Document Sample
lvm in linux Powered By Docstoc
					LVM

LOGICAL VOLUME MANAGER:
The LVM system organizes hard disks into Logical Volume (LV) groups. Essentially,physical hard disk
partitions (or possibly RAID arrays) are set up in a bunch of equal sized chunks known as Physical
Extents (PE). As there are several other conceptsassociated with the LVM system, let's start with some
basic definitions:

    Physical Volume (PV) is the standard partition that you add to the LVM mix.
    Normally, a physical volume is a standard primary or logical partition. It can also
    be a RAID array.

     Physical Extent (PE) is a chunk of disk space. Every PV is divided into a number
    of equal sized PEs. Every PE in a LV group is the same size. Different LV groups
    can have different sized PEs.

     Logical Extent (LE) is also a chunk of disk space. Every LE is mapped to a
     specific PE.

    Logical Volume (LV) is composed of a group of LEs. You can mount a
    File system such as /home and /var on an LV.

     Volume Group (VG) is composed of a group of LVs. It is the organizational
    group for LVM. Most of the commands that you'll use apply to a specific VG.




Advantages of LVM:

Logical volume management provides a higher-level view of the disk storage on a computer system than
the traditional view of disks and partitions. This gives the system administrator much more flexibility in
allocating storage to applications and users.

Storage volumes created under the control of the logical volume manager can be resized and moved
around almost at will, although this may need some upgrading of file system tools.

The logical volume manager also allows management of storage volumes in user-defined groups,
allowing the system administrator to deal with sensibly named volume groups such as "development" and
"sales" rather than physical disk names such as "sda" and "sdb".
STEPS TO CREATE LVM

   1.   Create a LVM partitions with FDISK Utility.
   2.   Create a PHYSICAL volume by ‘pvcreate’.
   3.   Create a VOLUME group by ‘vgcreate’.
   4.   Create a LOGICAL group by ‘lvcreate’.
   5.   Create a File System of Logical Volume.
   6.   MOUNT the LOGICAL volume.
   7.   Enter the entry of LVM in FSTAB




HOW TO CREATE LVM IN LINUX OPREATING SYSTEM:

STEPS:

1. Create a new partition
    fdisk /dev/hda

         Command (m for help): n
         First cylinder (1-256, default 1): default
         Last cylinder or +size or +sizeM or +sizeK (2-256,def 256): +200M

   Command (m for help): t
       Selected partition no(1-6):6
       Hex code (type L to list codes): 8e

   Command (m for help): n
       First cylinder (1-256, default 1): default
       Last cylinder or +size or +sizeM or +sizeK (2-256,def 256): +200M

   Command (m for help): t
       Selected partition no(1-7):7
       Hex code (type L to list codes): 8e

        Command (m for help): w

   [root@localhost /]# partprobe

2. Create a Physical Volume:

        [root@localhost /]# pvcreate /dev/hda? /dev/hda? ( ?-partition name )

3. Verify the size of Physical Volume:

        [root@localhost /]# pvdisplay

4. Create a Volume group:

        [root@localhost /]# vgcreate vg0 /dev/hda? /dev/hda?
5. Verify the size of Logical Volume:

       [root@localhost /]# vgdisplay

6. Create a Logical Volume:

       [root@localhost /]# lvcreate –L +50m –n data vg0

7. Create a File system:

       [root@localhost /]# mkfs.ext3 /dev/vg0/data

8. Create a folder where we have to mount Logical Volume:

       [root@localhost /]# mkdir sysadmin

9. Mount the Logical Volume in a mounting folder:

       [root@localhost /]# mount /dev/vg0/data /sysadmin

10. Give a entry in /etc/fstab of LVM:

       [root@localhost /]# vi /etc/fstab

         /dev/vg0/data        /sysadmin         ext3      defaults 1 2

11. Verify the size of Logical Volume:

       [root@localhost /]# lvdisplay /dev/vg0/data

12. Verify the Size on mounted directory:

       [root@localhost /]# df -h or df -h mounted directory name




HOW TO EXTEND THE LVM:

   1. Extend the size of LVM:

       [root@localhost /]# lvextend -L+400M /dev/vg0/data

   2. Resize the LVM partion:

       [root@localhost /]# resize2fs /dev/vg0/data to bring extended size online.

   3. Verify the Size on mounted directory:

       [root@localhost /]# df -h or df -h mounted directory name