Thursday, 8 November 2012

Is a partition resizeable ? / How to create a partition that can be extended in size ?


RHCE exercise : Is a partition resizeable ? / How to create a partition that can be extended in size in linux ?

Since i am an open source guy, i will explain to you , how to do this in linux.

This can be done using a concept called Logical Volume Management (LVM).

  We will go step by step for this,
 For this exercise,there are two main steps
Ø  Creating a lvm partition.

Ø  Resizing the partition.

Creating a lvm partition

1.First , one should create a partition of type lvm.Here are the steps below,
            fdisk  /dev/sda (your partition name)
               then choose n (to create new partition)
              give the size ..
              then choose  t (type of partition)
              select 8e which is a lvm partition.
Restart the system.

2.Now the partition is ready for lvm creation.
           There are three commands that needs to be performed.
                   Pvcreate  à physical volume creation
                  Vgcreate   à volume group creation
                  Lvcreate    à logical volume creation

The execution of the above commands are done  as follows,




Here note : /dev/sda3 is the targeted lvm partition.

3.Now the lvm partition is created.Makesure you format it and then mount it.Find the screenshot below for your reference.


          The partition is formatted using
                              Mkfs.ext4  /dev/vg005/lv005
                              Where vg005 – volume group name
                                           Lv005  - logical volume name
         Then the partition is mounted in /lvm  directory.



Resizing the partition
4.Now the lvm partition created can be resized.

         Extending the partition size (lvextend)
             1. Logical volume extend command.(lvextend).
            2.Check partition for any disk errors.
            3.Resize filesystem to the desired size.
       Find the screen shot below for the exact procedure.