Thursday, January 9, 2014

Extend LVM and filesystem on RHEL 6

If disks have been added when the system is running you will need have the kernel scan for new drives by running.


#'for i in `ls -1 /sys/class/scsi_host/`; do echo "- - -" > /sys/class/scsi_host/$i/scan;

Next run dmesg to get the name of the device.

 #dmesg
 scanning ...
 scsi 0:2:2:0: Direct-Access     DELL     PERC H700        2.10 PQ: 0 ANSI: 5
 sd 0:2:2:0: Attached scsi generic sg0 type 0
 sd 0:2:2:0: [sde] 875298816 512-byte logical blocks: (448 GB/417 GiB)
 sd 0:2:2:0: [sde] Write Protect is off
 sd 0:2:2:0: [sde] Mode Sense: 1f 00 00 08
 sd 0:2:2:0: [sde] Write cache: enabled, read cache: enabled, doesn't support    DPO or FUA
  sde: unknown partition table
  sd 0:2:2:0: [sde] Attached SCSI disk
  scsi 0:0:0:0: Direct-Access     ATA      Crucial_CT960M50 MU02 PQ: 0 ANSI: 5
  scsi 0:0:1:0: Direct-Access     SEAGATE  ST91000640SS     AS03 PQ: 0 ANSI: 6
  scsi 0:0:2:0: Direct-Access     SEAGATE  ST91000640SS     AS03 PQ: 0 ANSI: 6
  scsi 0:0:3:0: Direct-Access     SEAGATE  ST91000640SS     AS03 PQ: 0 ANSI: 6
  scsi 0:0:4:0: Direct-Access     ATA      Crucial_CT960M50 MU02 PQ: 0 ANSI: 5
  ...
You can verify you device with the following command.

#fdisk -l /dev/sde 

   Disk /dev/sde: 448.2 GB, 448152993792 bytes
  255 heads, 63 sectors/track, 54484 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disk identifier: 0x00000000
 ~                        

Next you can view the current volume group as shown below.

# vgs
 VG         #PV #LV #SN Attr   VSize   VFree  
 VolGroup00   1   3   0 wz--n- 476.25g 256.00m
 VolGroup01   1   1   0 wz--n-   4.55t 507.79g

Now we will create a physical volume on /dev/sde
# pvcreate /dev/sde    
Physical volume "/dev/sde" successfully created  

 Then you will need to add the Physical Volume to the Volume Group.

 # vgextend VolGroup00 /dev/sde
   Volume group "VolGroup00" successfully extended

Now the vgs command show that our Volume Group has been extended.
 # vgs     
   VG         #PV #LV #SN Attr   VSize   VFree    
   VolGroup00   2   3   0 wz--n- 893.59g 417.59g  
   VolGroup01   1   1   0 wz--n-   4.55t 507.79g
 Now you can view the Logical Volume that needs to be extended.
   
 #  lvs   
   LV       VG         Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync    Convert   
   LogVol00 VolGroup00 -wi-ao---  12.00g                                                
   LogVol01 VolGroup00 -wi-ao---   1.00g                                                
   LogVol02 VolGroup00 -wi-ao--- 463.00g                                                
   LogVol00 VolGroup01 -wi-ao---   4.05t
Then we can exttend the Logival Volume by running the following
# lvresize -L 830g /dev/VolGroup00/LogVol02   
     Extending logical volume LogVol02 to 830.00 GiB
       Logical volume LogVol02 successfully resized
  
 I like to vie my changed to insure every thing worked as I hoped.
# lvs
   LV       VG         Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync    Convert  
     LogVol00 VolGroup00 -wi-ao---  12.00g                                               
     LogVol01 VolGroup00 -wi-ao---   1.00g                                               
     LogVol02 VolGroup00 -wi-ao--- 830.00g                                               
     LogVol00 VolGroup01 -wi-ao---   4.05t                    
 ~                                                         
 All that is left is to extend our file system.with the command:
 # resize2fs  /dev/VolGroup00/LogVol02
 resize2fs 1.41.12 (17-May-2010)  
 Filesystem at /dev/VolGroup00/LogVol02 is mounted on /var/lib/mysql_ssd; on-    line resizing required
 old desc_blocks = 29, new_desc_blocks = 52
 Performing an on-line resize of /dev/VolGroup00/LogVol02 to 217579520 (4k)      blocks.
 The filesystem on /dev/VolGroup00/LogVol02 is now 217579520 blocks long.
All done. 

No comments:

Post a Comment