[RHEL] Extend Disk Space using LVM

[RHEL] Extend Disk Space using LVM: Some times we need to Extend Volume space for  increasing the disk space of RHEL server which using LVM disks partations. in this topic we discuss  how to Extend Disk Space using LVM 

[RHEL] Extend Disk Space using LVM:

Before going to Extend Volume space for increasing the disk space we need to provision free disk space to the server.

Note: Please take a healthy backup of the server before going to perform Extend Volume space using below commands.

Check the Disk space and partations

# df -h

Extend Disk Space using LVM: RHEL 6/7

# pvscan

  PV /dev/sda3   VG VOLGROUP        lvm2 [<65.50 GiB / 0    free]
  PV /dev/sda4                      lvm2 [30.00 GiB]
  Total: 2 [<95.50 GiB] / in use: 1 [<65.50 GiB] / in no VG: 1 [30.00 GiB]

# vgextend VOLGROUP /dev/sda4

  Volume group "VOLGROUP" successfully extended

# pvscan

  PV /dev/sda3   VG VOLGROUP        lvm2 [<65.50 GiB / 0    free]
  PV /dev/sda4   VG VOLGROUP        lvm2 [<30.00 GiB / <30.00 GiB free]
  Total: 2 [95.49 GiB] / in use: 2 [95.49 GiB] / in no VG: 0 [0   ]

# vgdisplay

  --- Volume group ---
  VG Name               VOLGROUP
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  12
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               95.49 GiB
  PE Size               4.00 MiB
  Total PE              24446
  Alloc PE / Size       16788 / <65.58 GiB
  Free  PE / Size       7658 / 29.91 GiB
  VG UUID               PB1IPY-T00e-XVzD-WAin-IGIt-YeVr-KzUy61

# vgs

VG       #PV #LV #SN Attr   VSize  VFree
VOLGROUP   2   6   0 wz--n- 95.49g 29.91g

*** for extend within the LMV

# lvextend -L+25 /dev/mapper/VOLGROUP-home
 
Rounding size to boundary between physical extents: 28.00 MiB.
Size of logical volume VOLGROUP/home changed from 10.00 GiB (2561 extents) to 10.03 GiB (2568 extents).
Logical volume VOLGROUP/home successfully resized.

*** For extend with another LMV

# lvextend /dev/mapper/VOLGROUP-home /dev/sda4

Size of logical volume VOLGROUP/home changed from <10.09 GiB (2582 extents) to 40.00 GiB (10240 extents).
Logical volume VOLGROUP/home successfully resized.

*** For extend with another LMV with custome space.

# lvextend -L+10 /dev/mapper/VOLGROUP-home /dev/sda4

Size of logical volume VOLGROUP/home changed from <10.09 GiB (2582 extents) to 20.09 GiB (10240 extents).
Logical volume VOLGROUP/home successfully resized.

Reduce Disk space

# lvreduce -L 10G /dev/rhel/home
# vgs
# lvscan


Save changes : For RHEL 6

# resize2fs /dev/mapper/VOLGROUP-home

resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/VOLGROUP-home
Couldn't find valid filesystem superblock.

Save changes : For RHEL7

# xfs_growfs /dev/mapper/VOLGROUP-home

meta-data=/dev/mapper/VOLGROUP-home isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2621440 to 2636800

Comments

Popular posts from this blog

How to install glibc 2.14 on RHEL 6/ RHEL 7/ CentOS 7

Export and Import users/groups and OU in AD Server 2008 using LDIFDE command.

How to Set Up and Configure latest yum repository on CentOS