Monday 18 November 2013

How to extend LVM

say the disk is 97% fill, then what approach you will take

1. check the disk is full or not using df -h

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              25G  4.9G   19G  21% /
tmpfs                 593M     0  593M   0% /dev/shm
/dev/mapper/vg--ctechz-lvm--ctechz
                      591M  542M   20M  97% /lvm-ctechz


2. Find out the Volume group(VG) containing the logical volume(LV)

# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg-ctechz/lvm-ctechz
  VG Name                vg-ctechz
  LV UUID          jZEuoN-16MG-30eX-SZaI-8ETO-ZguH-YRVyeN
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                600.00 MB
  Current LE             150
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@localhost ~]# lvs
  LV         VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lvm-ctechz vg-ctechz -wi-ao 600.00M

3. Check the Volume Group(VG) whether we can extend it or not, check is their any free space in volume group or not

# vgdisplay
  --- Volume group ---
  VG Name               vg-ctechz
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  14
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.04 GB
  PE Size               4.00 MB
  Total PE              266
  Alloc PE / Size       150 / 600.00 MB
  Free  PE / Size       116 / 464.00 MB
  VG UUID          ui4JTr-JOwC-VCvG-5Evc-poOD-3Klr-hM3feq

[root@localhost ~]# vgs
  VG        #PV #LV #SN Attr   VSize VFree
  vg-ctechz   2   1   0 wz--n- 1.04G 464.00M

If we have free space in VG extend it

# lvextend -L +wanted size/full new size /dev/vgname/lvname

If we want to extend an LVM of size 110MB to 150MB then we can give

# lvextend -L +40M /dev/vgname/lvname  OR

# lvextend -L 150M /dev/vgname/lvname

We can also give it with block size

# lvextend -l +multiple of PE size /dev/vgname/lvname
                2,4,8,16
in the above case if the PE Size is 4MB we can done the extension by

lvextend -l +10 /dev/vgname/lvname

In this setup
# lvextend -L +300M /dev/vg-ctechz/lvm-ctechz
  Extending logical volume lvm-ctechz to 900.00 MB
  Logical volume lvm-ctechz successfully resized


4.Then format this extended size to ext3
     # resie2fs /dev/vgname/lvname

# resize2fs /dev/vg-ctechz/lvm-ctechz
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg-ctechz/lvm-ctechz is mounted on /lvm-ctechz; on-line resizing required
Performing an on-line resize of /dev/vg-ctechz/lvm-ctechz to 230400 (4k) blocks.
The filesystem on /dev/vg-ctechz/lvm-ctechz is now 230400 blocks long.

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              25G  4.9G   19G  21% /
tmpfs                 593M     0  593M   0% /dev/shm
/dev/mapper/vg--ctechz-lvm--ctechz
                      885M  542M  301M  65% /lvm-ctechz


Earlier only 20MB is available and 97% full now we extended the lvm and 301MB available and 65% Free now.



# vgs
  VG        #PV #LV #SN Attr   VSize VFree
  vg-ctechz   2   1   0 wz--n- 1.04G 164.00M

# lvs
  LV         VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lvm-ctechz vg-ctechz -wi-ao 900.00M
 

Now the total lvm size is 900MB

# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg-ctechz/lvm-ctechz
  VG Name                vg-ctechz
  LV UUID                jZEuoN-16MG-30eX-SZaI-8ETO-ZguH-YRVyeN
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                900.00 MB
  Current LE             225
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

No comments:

Post a Comment