Monday, March 23, 2015

Adding disk space to a Linux VM

Adding disk space to a Linux VM

  1. Log in to the target system
  2. Identify the partition that will need to be extended
  3. Identify the associated volume group where the logical volume resides
  4. If there is enough free space in the Volgroup (noted by running vgdisplay on the appropriate VolGroup) skip down to lvextend.
  5. Open up VCenter and navigate to the appropriate VM
  6. Right click on the VM and select Edit Settings
  7. Click Add
  8. Select Hard Disk
  9. Ensure Create a new virtual disk is selected
  10. Click Next
  11. Configure the size that is requested
  12. Select thin Provision where possible
  13. If a specific location is required for this disk configure further, else keep the vmdk with the virtual machine (default)
  14. Click Next
  15. Click Next
  16. Click Finish
  17. Click OK
  18. SSH back in to system
  19. Type in fdisk -l (Shows you the current disks on the system, new disk is not in the list)
  20. pvs will also show you the current physical volumes and their associated volume groups
  21. Execute the following command to make sure the OS picks up the new device
    # echo "- - -" > /sys/class/scsi_host/host0/scan
  22. Create the physical drive
    # pvcreate /dev/<device_name> 
  23. Execute the folling command to ensure the pysical drive is added to the appropriate volume group
    # vgextend <VolGroup_NAME> /dev/<device_name>
  24. Execute vgdisplay, output shows the extra space available
  25. Extend the logical volume
    # lvextend -L +<AMOUNTOF_STORAGE_TOADD>G /dev/mapper/<LOGICAL_VOLUME>
  26. In RHEL5 and above you can run the following command to complete the addition of the space to the logical drive
    # resize2fs /dev/mapper/<LOGICAL_VOLUME>
  27. check filesystem with df -h to ensure that the new space if availble