[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

resizing LVM on VMware Linux host

Posted on 2011-10-11
5
Medium Priority
?
822 Views
Last Modified: 2012-08-13
hi,

I'd like to ask you if someone could provide an answer for my question.

We have VMware RedHat Linux host, which has one virtual disk LVM configured:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             6.8G  4.9G  1.6G  76% /
tmpfs                1014M     0 1014M   0% /dev/XXX
/dev/sdb1             197G  181G  6.0G  97% /YYY
/dev/sdc1              20G   19G  503M  98% /log
/dev/mapper/vg0-lvol0
                       98G   64G   30G  69% /ZZZ

I've resized the last disk from 100gb to 350gb in VMware vCenter on host, started the host, but I can't see the free space or something else which should indicate that the disk was expanded.
pvscan:

  PV /dev/sdd1   VG vg0   lvm2 [99.98 GB / 1008.00 MB free]
  Total: 1 [99.98 GB] / in use: 1 [99.98 GB] / in no VG: 0 [0   ]

do you have any ideas how should I rescan it or what is necessary to perform to see&resize the disk.

thanks so much in advance.
0
Comment
Question by:ZUNO
5 Comments
 
LVL 124

Assisted Solution

by:Andrew Hancock (VMware vExpert / EE MVE^2)
Andrew Hancock (VMware vExpert / EE MVE^2) earned 332 total points
ID: 36947778
What you need to remember is that you have expanded the disk which is presented to the OS.

Disk Expansion does not expand the partitions inside the OS, you need to expand the partition manually.

Before making any changes to the partition structure of the disk, ensure you have a full backup, not a snapshot.

1. Resize partition with Gparted Live CDROM

i. Download Gparted Live CDROM (http://gparted.sourceforge.net/livecd.php).

ii. Upload the cdrom iso to the vSphere ESX/ESXi datastore.

iii. Mount the cdrom or iso on the virtual machine.

iv. Shutdown and restart the virtual machine booting from the cdrom.


v. Select Resize partition.

Here is a Tutorial Walkthorugh of how to resize a partition with a GParted Live CDROM

http://gparted.sourceforge.net/larry/resize/resizing.htm

http://www.howtogeek.com/howto/windows-vista/using-gparted-to-resize-your-windows-vista-partition/

0
 
LVL 124
ID: 36947782
or here, this article may help you

LVM Resizing Guide
http://www.tcpdump.com/kb/os/linux/lvm-resizing-guide/intro.html
0
 
LVL 23

Assisted Solution

by:bhanukir7
bhanukir7 earned 332 total points
ID: 36948630
hi Zuno,

as mentioned you can use fdisk to first format the free space as a new partition and use the command

vgextend "existing vol group" new partition created after extending the disk.

however you cannot extend a existing LVM parition with newly added free space if there is a swap partitition between

LVM can be extended only between contigious disk space

i ran into issue when my redhat box had the / volume mounted on logvol01 and swap on logvol00 as by default the swap parition is created on the end of disk

regards
bhanu
0
 
LVL 2

Accepted Solution

by:
dbarber012577 earned 336 total points
ID: 36956501
I think everyone has posted good info. See if this helps:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006371

To extend the logical volume:

Note: These steps only apply to EXT3 file systems.
 
Caution: VMware recommends having a complete backup of the virtual machine prior making these changes.
1.Power off the virtual machine.
2.Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
3.Power on the virtual machine.
4.Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:

fdisk -l


5.Create a new primary partition:

a.Run the command:

fdisk /dev/sda (depending the results of the step 4)
 
b.Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.
c.Press n to create a new primary partition.  
d.Press p for primary.
e.Press 3 for the partition number, depending the output of the partition table print.
f.Press Enter two times.
g.Press w to write the changes to the partition table.


7.Restart the virtual machine.
8.Run this command to verify that the changes were saved to the partition table and that the new partition has an 83 type:

fdisk -l


9.Run this command to convert the new partition to a physical volume:

pvcreate /dev/sda3


10.Run this command to extend the physical volume:

vgextend VolGroup00 /dev/sda3


11.Run this command to verify how many physical extents are available to the Volume Group:

vgdisplay VolGroup00 | grep "Free"


12.Run the following command to extend the Logical Volume:

lvextend -L+#G /dev/VolGroup00/LogVol00

Where # is the number of Free space in GB available as per the previous command.


13.Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

ext2online /dev/VolGroup00/LogVol00

Note: Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.


14.Run the following command to verify that the / filesystem has the new space available:

df -h /


0
 

Author Comment

by:ZUNO
ID: 36956846
thanks guys, you all have posted very useful info, but ..

I was thinking if there's a possible solution to do it without restart of VM and more simple - so finally, I assigned new virtual disk to that VM, assigned him to volume group, using pvmove I moved the old partition to new one and finally I've resized logical volume and filesystem ...

this solution was less complex and without hurting me a lot :) , just have one restart & old disk was removed as it was moved to new one, so no longer it was needed ...
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
Teach the user how to use vSphere Update Manager to update the VMware Tools and virtual machine hardware version Open vSphere Client: Review manual processes for updating VMware Tools and virtual hardware versions: Create a new baseline group in vSp…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question