Thursday, November 26, 2015

Online add space in existing disk by PVRESIZE command in RHEL

Step 1) scan disk
# fdisk -l | grep -i Disk | grep -i dev
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
Disk /dev/sda: 64.4 GB, 64424509440 bytes

Scan scsi disk:
# ls /sys/class/scsi_host/
host0  host1  
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan


or, scan block disk if require
# echo 1 > /sys/block/sdb/device/rescan

# fdisk -l | grep -i Disk
Disk /dev/sdb: 64.4 GB, 64424509440 bytes
Disk /dev/sda: 64.4 GB, 64424509440 bytes

Step 2) resize physical disk
# pvresize /dev/sdb
  Physical volume "/dev/sdb" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

# pvs
  PV         VG          Fmt  Attr PSize  PFree
  /dev/sdb   vg_xxxxxxxx lvm2 a--  60.00g 20.00g


Now additional disk is visible by vgdisplay command
# vgdisplay
  Format                lvm2
  VG Access             read/write
  VG Status             resizable
  VG Size               60.00 GiB  <--------
  PE Size               4.00 MiB
  Total PE              15359
  Alloc PE / Size       10239 / 40.00 GiB
  Free  PE / Size       5120 / 20.00 GiB <--------

Step 3) Extend existing volume
# lvextend -L +20G /dev/vg_xxxxxxxx/lv_xxxxxxxx -t
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Size of logical volume vg_xxxxxxxx/lv_xxxxxxxx changed from 40.00 GiB (10239 extents) to 60.00 GiB (15359 extents).
  Logical volume lv_xxxxxxxx successfully resized

or, you can extend 100% disk space
#/usr/sbin/lvextend -l +100%FREE /dev/vg_xxxxxxxx/lv_xxxxxxxx -t

# lvextend -L +20G /dev/vg_xxxxxxxx/lv_xxxxxxxx
  Size of logical volume vg_xxxxxxxx/lv_xxxxxxxx changed from 40.00 GiB (10239 extents) to 60.00 GiB (15359 extents).
  Logical volume lv_xxxxxxxx successfully resized

# resize2fs /dev/vg_xxxxxxxx/lv_xxxxxxxx
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_xxxxxxxx/lv_xxxxxxxx is mounted on /xxxxxxxx; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 4
Performing an on-line resize of /dev/vg_xxxxxxxx/lv_xxxxxxxx to 15727616 (4k) blocks.
The filesystem on /dev/vg_xxxxxxxx/lv_xxxxxxxx is now 15727616 blocks long.

Step 4) Check file system
# df -h

No comments:

Post a Comment