Wednesday, September 19, 2012

                Sometimes, If logs are coming in one in LVM partition and you can't stop application or delete logs. So there is only one way to extend the LVM partition. i.e. Extend Logical Volume. But for extending the logical volume, there is need of enough space (our needed free space) in respective Volume group of that logical volume. Following are the simple steps to extend the Volume Group:
Step1: Check the Volume Group details and free space in that. We have 96MB free space in Volume group (MyVolume). But we need more 500MB space in same Volume Group.
[root@server92 ~]#
[root@server92 ~]# vgs
  VG                         #PV       #LV       #SN        Attr        VSize                     VFree
  MyVolume       1              1              0              wz--n-   496.00m               96.00m
  vgsrv                   1              3              0              wz--n-                   4.47g                     384.00m
[root@server92 ~]#
[root@server92 ~]#
Step2: We will create a new LVM partition of 500MB in hard disk in which free space is available and  then we will create its Physical Volume.
[root@server92 ~]# fdisk -cu /dev/sda
Disk /dev/sda: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00050f52

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      526335      262144   83  Linux
/dev/sda2          526336     9914367     4694016   8e  Linux LVM
/dev/sda3         9914368    10938367      512000    5  Extended
/dev/sda4        10938368    11962367      512000   83  Linux  /// We have already created partition, need
/dev/sda5         9916416    10938367      510976   8e  Linux LVM                                        //to change only type.

Command (m for help): t
Partition number (1-5): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@server92 ~]#
[root@server92 ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
[root@server92 ~]#
[root@server92 ~]# cat /proc/partitions
major minor  #blocks  name

   8        0   41943040 sda
   8        1     262144 sda1
   8        2    4694016 sda2
   8        3          1 sda3
   8        4     512000 sda4
   8        5     510976 sda5
 253        0     557056 dm-0
 253        1    3473408 dm-1
 253        2     409600 dm-2
 253        3     262144 dm-3
[root@server92 ~]#
[root@server92 ~]# pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created
[root@server92 ~]#
Step3:  Now add this newly created partition in MyVolume Volume Group. i.e. extend the Volume Group as:
[root@server92 ~]#
[root@server92 ~]# pvs
  PV                        VG       Fmt  Attr PSize   PFree
  /dev/sda2         vgsrv    lvm2 a-     4.47g 384.00m
  /dev/sda4           lvm2 a-   500.00m 500.00m
  /dev/sda5         MyVolume lvm2 a-   496.00m  96.00m
[root@server92 ~]#
[root@server92 ~]# vgextend MyVolume /dev/sda4
  Volume group "MyVolume" successfully extended
[root@server92 ~]#
[root@server92 ~]# vgs
  VG                        #PV #LV #SN Attr   VSize   VFree
  MyVolume       2   1   0 wz--n- 992.00m 592.00m
  vgsrv                   1   3   0 wz--n-   4.47g 384.00m
[root@server92 ~]#

Now, you have free space of 592 MB in Volume group (MyVolume). And you can extend the logical volume by one more command:
[root@server92 ~]# df -kh
Filesystem                                          Size  Used Avail Use% Mounted on
/dev/mapper/vgsrv-root             3.3G  2.1G  1.1G  67% /
tmpfs                                                    246M     0  246M   0% /dev/shm
/dev/sda1                                           248M   30M  206M  13% /boot
/dev/mapper/vgsrv-home           248M   11M  226M   5% /home
/dev/mapper/MyVolume-MyLogicalVol       388M   11M  358M   3% /MyData
[root@server92 ~]#
[root@server92 ~]# lvextend -L +300M /dev/mapper/MyVolume-MyLogicalVol
  Extending logical volume MyLogicalVol to 700.00 MiB
  Logical volume MyLogicalVol successfully resized
[root@server92 ~]#
[root@server92 ~]#
[root@server92 ~]# resize2fs /dev/mapper/MyVolume-MyLogicalVol
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/MyVolume-MyLogicalVol is mounted on /MyData; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/MyVolume-MyLogicalVol to 716800 (1k) blocks.
The filesystem on /dev/mapper/MyVolume-MyLogicalVol is now 716800 blocks long.

[root@server92 ~]# df -kh
Filesystem                                          Size  Used Avail Use% Mounted on
/dev/mapper/vgsrv-root             3.3G  2.1G  1.1G  67% /
tmpfs                                                     246M     0  246M   0% /dev/shm
/dev/sda1                                           248M   30M  206M  13% /boot
/dev/mapper/vgsrv-home            248M   11M  226M   5% /home
/dev/mapper/MyVolume-MyLogicalVol       679M   11M  633M   2% /MyData
[root@server92 ~]#
If you want to know more about the Logical Volume extension then click here.
Posted by Machindra Dharmadhikari On 9/19/2012 10:30:00 AM 1 comment

1 comment:

  1. One of the nigh muscular tools that can be used you Ameliorate Traffic generation, near
    do not dig the existent economic value of home business web development.


    My web-site Site

    ReplyDelete

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner