Extend SAN disk under Linux LVM

In Linux server, How to extend the SAN disk under LVM , after the LUN expanded from SAN? 

This article will explain you, how to do this. we are going to expand size of the SAN disk which is 20GB to 75GB under LVM. Basically, Linux detects the new size after a LUN scan, but LVM won't recognize expanded size of the disk. Let us see, how we are going to achieve this.

1. Scan for new LUNS. Refer Scan and Configure New LUNS for scanning LUNS in Linux

2. After scanning, check physical size of  the drive now.

# fdisk -l /dev/sdb
       
Disk /dev/sdb: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Device Boot      Start         End      Blocks   Id  System

Now,  Linux recognized the new size as 75 GB.

3. Check the LVM

# pvs   
PV         VG      Fmt  Attr PSize  PFree
/dev/sda3  system  lvm2 a-   16.89G  2.92G
/dev/sdb   system2 lvm2 a-   20.00G 96.00M

 This command still reported 20GB for the LVM disk, Lets do a scan now:

# pvscan
# vgscan
# lvscan

# pvs   
PV         VG      Fmt  Attr PSize  PFree
/dev/sda3  system  lvm2 a-   16.89G  2.92G
/dev/sdb   system2 lvm2 a-   20.00G 96.00M

4. After the scan also, LVM still reports the disk as 20GB. So let us extend the size manually.
       

#  pvresize --setphysicalvolumesize 70G /dev/sdb
#  pvs

PV            VG      Fmt  Attr PSize  PFree
/dev/sda3  system  lvm2 a-   16.89G  2.92G
/dev/sdb   system2 lvm2 a-   70.00G 96.00M

Now LVM reports the new size of the disk.  Let us do a scan again, so that VG takes this new PV size into account.

# pvscan
# vgscan
# lvscan

5. Now, we can extend the logical volume size:

#  lvextend -L +50G /dev/system2/app
#  resize_reiserfs /dev/system2/app

# pvs
# vgs
VG      #PV #LV #SN Attr   VSize  VFree
system    1   5   0 wz--n- 16.89G  2.92G
system2   1   1   0 wz--n- 70.00G 96.00M

# lvs
LV   VG      Attr   LSize  Origin Snap%  Move Log Copy%
Opt  system  -wi-ao  2.00G
root system  -wi-ao  1.00G
tmp  system  -wi-ao  2.00G
usr  system  -wi-ao  2.97G
var  system  -wi-ao  6.00G
app  system2 -wi-a- 69.90G
       
6. Finally verify the space

# df -h  /app
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/system2-app
                           70G  5.5G   65G   8% /app
Thats all..! we are done..enjoy..

Share this

Related Posts

Previous
Next Post »

7 comments

Write comments
Anonymous
July 19, 2012 at 11:51 AM delete

Hi Friend , i have one doubt after reading this article, after pvresize /dev/sdb. is it not need to extend the vg space vgextend +50G /dev/sdb

Reply
avatar
July 20, 2012 at 7:28 PM delete

I believe it is not needed to vgextend.

Reply
avatar
December 19, 2012 at 2:22 PM delete

Thanks so much! Brilliantly works!!!

Reply
avatar
December 19, 2012 at 2:23 PM delete

Brilliant! it works fine.
Thanks for the steps.

Reply
avatar
September 25, 2013 at 9:02 PM delete

Hi,

I just want to confirm whether in this case our old in lv will be safe or lose ?

Reply
avatar
Anonymous
August 16, 2014 at 7:14 PM delete

well you just resized your disk to 70G instead of 75.... would have been better to see how to use all space

Reply
avatar
September 11, 2020 at 8:15 PM delete

Friend, thank you very much for the article, I researched several and none worked 100% as yours, saved my day.

Reply
avatar

What do you think about this Article? Add your Opinion..! EmoticonEmoticon