How to reduce LVM partition size in RHEL and CentOS

Now we are going to learn very useful & interesting topic "How to reduce/extend LVM size" with real time example.hope this article very helpful for you.
For example scenario, I have added some storage space to linux machine,we need to scan hosts to display in linux machine, we can scan all hots/LUN's by using below commands at the time.
------------------------------------------------------ 


Use below command to scan hosts/LUN's.
ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done

 Use below command to verify newly added device/stroage
#lsblk

Use below command to format /dev/sdb
#fdisk /dev/sdb


Below commands helpful for complete format.
#n
#p
enter enter
#t
#8e
p
#wq

Below command used to update partition info to kernal.
partprobe /dev/sdb1

try below command to create pv(Physical volume)
#pvcreate /dec/sdb1

Try below command to create volume group
#vgcreate VG00 /dev/sdb1

Try below command to create new LVM
#lvcreate -n lvm1 -L 4G VG00

Use below command to format.

mkfs.ext4 /dev/VG00/lvm1

Use below command to mount file system.
mount /dev/VG00/lvm1 /test3/

Use below command to update mount points.
# mount -a
              
Use below commands to verify file systems.
df -h

              
Use below commands to unmount file system.#umount /home/

Use below command to run file system error check.
#e2fsck -f /dev/VG00/lvm1
                
Use below command to resize the file system,
Reduce or Shrink the size of /dev/VG00/lvm1 to desire size.
#resize2fs /dev/VG00/lvm1 4G


Use below command to reduce lvm size






#lvreduce -L 4G /dev/VG00/lvm1

Use below command to extend lvm size





#lvextend -l +100%FREE -r dev/VG00/lvm1

Use below command to run file system error check.
#e2fsck -f dev/VG00/lvm1
             
Mount the file system and verify its size.
#mount dev/VG00/lvm1
--------------------------
How to extend LVM, fellow below steps.

lvextend -L +4G /dev/VG00/lvm1 -r

Below command used to check physical volumes info.
#pvs

#pvdisplay /dev/sdX


Below command used to check VG info.
#vgs
#vgdisplay vg00

Use below command to check logical volume basic info

#lvs
#lvdisplay


Thank you, please drop your query in below.

Comments

  1. thank you so much it's very help full in realtime.

    ReplyDelete

Post a Comment

Popular posts from this blog

Awk command with simple examples

Learn Linux in Telugu | Linux complete Free Course in Telugu by 7Hills

rsync Command Examples | rsync Command In Telugu