Detailed explanation of LVM expansion under CentOS

Time:2020-3-24

Because the production needs to expand the capacity of the / data directory, from the original 90g to 190g, increasing the space of 100g

The production environment is RHEL server, EMC storage with back-end connected by optical switch. First, the idle hard disk is raid divided into Lun on EMC storage and mapped to production RHEL server.

(Note: the premise of this expansion is that the partition must be completed in LVM format.)

1、 Original server disk information

#df -H

/dev/datavg/lv_data

                      90G   81G   9G  90% /data

#lvdisplay

— Logical volume —

LV Name                /dev/datavg/lv_data

VG Name                datavg

LV UUID                Sgpcu1-7Xhr-0gwH-qjJ6-QwBB-k2KA-9DJvFt

LV Write Access        read/write

LV Status              available

# open                 1

LV Size                90.00 GB

Current LE             24882

Segments               10

Allocation             inherit

Read ahead sectors     auto

– currently set to     256

 Block device           253:1

2、 Restart the server, and after identifying the newly added Lun on EMC, expand the datavg volume on the server side

#powerrmt display dev=all

Pseudo name=emcpowery

CLARiiON ID=CKM00110900942 [SG_DRAGON]

Logical device ID=6006016003602C00F0154D04917BE011 [LUN 211]

state=alive; policy=CLAROpt; priority=0; queued-IOs=0;

Owner: default=SP A, current=SP A       Array failover mode: 1

==============================================================================

————— Host —————   – Stor –   — I/O Path —  — Stats —

###  HW Path               I/O Paths    Interf.   Mode    State   Q-IOs Errors

==============================================================================

7 qla2xxx                  sdan      SP B0     active  alive       0      0

5 qla2xxx                  sdas      SP B1     active  alive       0      0

7 qla2xxx                  sdbo      SP A1     active  alive       0      0

5 qla2xxx                  sdq       SP A0     active  alive       0      0

#powerrmt config

#powerrmt save

3、 Step:

Fdisk / dev / emcpower1 and press n to add a new partition;

Enter p to create the primary partition, and press enter twice to distribute all the spaces to this partition;

Input t to convert partition type; input 8e to convert to Linux LVM partition;

Enter w write save to exit.

Create PV

[[email protected] /]# pvcreate  /dev/ emcpowery1

Join to an existing logical volume group

[[email protected] /]# vgextend  datavg  /dev/ emcpowery1

Capacity expansion for LVM

[[email protected] /]# lvextend -L +100G /dev/datavg/lv_data

Check the relationship between the corresponding inode and block of LVM device

[[email protected] /]# e2fsck –f /dev/datavg/lv_data

Make the increased capacity effective

[[email protected] /]# resize2fs /dev/datavg/lv_data

Four, validation

#df -H

/dev/datavg/lv_data

                      190G   81G   109G  43% /data

#lvdisplay

— Logical volume —

LV Name                /dev/datavg/lv_data

VG Name                datavg

LV UUID                Sgpcu1-7Xhr-0gwH-qjJ6-QwBB-k2KA-9DJvFt

LV Write Access        read/write

LV Status              available

# open                 1

LV Size                190.00 GB

Current LE             39882

Segments               10

Allocation             inherit

Read ahead sectors     auto

– currently set to     256

Block device           253:1