LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices



Reply
 
Search this Thread
Old 12-23-2009, 03:11 PM   #1
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Rep: Reputation: 0
LVM and Resizing with VMWare


I wonder if anyone can help me with this LVM resizing problem I have. I've not really used LVM to any great extent before, but I thought that I'd try it out now that we're moving to a VSphere environment.

So, I created a virtual disc with thin provisioning of 20GB and installed Linux on it using 100MB for /boot (on ext3) and a Volume Group taking up the rest of the drive with the logical volumes created within it. Everything OK so far.

Now, what I did next was to increase the size of the disc in VSphere to 30GB and rescanned the drive so the 30GB was available in Linux as you can see below;

Code:
fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
Now, what I want to do is increase the size of the Volume Group so that it uses the extra space on /dev/sda, ready to extend one or more of the logical volumes but I have no idea how to do this, as you can see the Volume Group is still the original size, eventhough the device is now larger;

Code:
vgdisplay
  --- Volume group ---
  VG Name               rootvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.88 GB
  PE Size               32.00 MB
  Total PE              636
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       0 / 0
  VG UUID               rWAxdp-PEki-WQko-eLK9-OX5M-jRny-QHsDpN
Can anyone enlighten me on how to do this?

Thanks

John
 
Old 12-23-2009, 03:43 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
Review of the lvm man page suggests pvresize.

Review of the pvresize man page suggests doing "pvresize /dev/sda2" will make the physical volume recognize the fdisk (partition) changes.

When working with LVM typing "man lvm" will give you an overview of what each of the commands done. Then typing man on the command (e.g. "man pvresize") will give you details as to what the specific command does.
 
Old 12-23-2009, 04:06 PM   #3
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlightner View Post
Review of the lvm man page suggests pvresize.

Review of the pvresize man page suggests doing "pvresize /dev/sda2" will make the physical volume recognize the fdisk (partition) changes.

When working with LVM typing "man lvm" will give you an overview of what each of the commands done. Then typing man on the command (e.g. "man pvresize") will give you details as to what the specific command does.
Thanks for that, I had seen that and tried it, but this is what I get;

Code:
 pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
That certainly looks positive... but;

Code:
 vgdisplay
  --- Volume group ---
  VG Name               rootvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  11
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.88 GB
  PE Size               32.00 MB
  Total PE              636
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       0 / 0
  VG UUID               rWAxdp-PEki-WQko-eLK9-OX5M-jRny-QHsDpN
VG Size hasn't changed to take up the extra ~10GB
 
Old 12-23-2009, 06:57 PM   #4
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: always back to Fedora
Posts: 241

Rep: Reputation: 50
I think Oracle Enterprise Linux is Based on Redhat Enterprise Linux, in which case you probably have a very useful gui called "system-config-lvm". Have you tried using this?

If you don't have the gui, you will need to use the lvm shell. The command vgextend comes to mind.

This link http://tldp.org/HOWTO/LVM-HOWTO/is the one you need for all of your answers. It will probably have examples of your scenario.

Of course before you do anything like this, backup all of your data and have a contingency plan in place in case anything _bad_ happens. Good luck.
 
Old 12-24-2009, 01:12 AM   #5
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ArfaSmif View Post
I think Oracle Enterprise Linux is Based on Redhat Enterprise Linux, in which case you probably have a very useful gui called "system-config-lvm". Have you tried using this?

If you don't have the gui, you will need to use the lvm shell. The command vgextend comes to mind.

This link http://tldp.org/HOWTO/LVM-HOWTO/is the one you need for all of your answers. It will probably have examples of your scenario.

Of course before you do anything like this, backup all of your data and have a contingency plan in place in case anything _bad_ happens. Good luck.
Indeed it is based on RHEL, but the graphical tool doesn't seem to offer anything to resize a Volume Group.

I'm doing this on a scratch VM which I set up to specifically to test this out, so I don't have to worry about losing data... thanks for the reminder though! :-)

I've been looking for days to find a solution to a simple problem, and there really doesn't seem to be anything on this, so I think I must be misunderstanding something... It seems really simple, I set up a Volume Group at 20Gig, created some logical volumes in it, increased the underlying drive size to 30Gig, and now want to extend one of the lvs to take up the remaining space. I thought I would have to increase the VG first, before increasing the size of the LV... but perhaps not?

Any help appreciated.

Thanks

John
 
Old 12-24-2009, 02:39 AM   #6
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
OK, I've re-read the docs about LVM and there is definitely something not working here.

We know that the OS can see the extra space (highlighted in red);
Code:
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
So, rather than increase the VG size, I think I need to increase the size of Physical Volume first, as this is underlying physical storage unit of an LVM logical volume... So, I'll do that;

Code:
pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
This looks promising, it has told me that 1 physical volume has resized. Lets take a look at what it now looks like;
Code:
pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rootvg
  PV Size               19.89 GB / not usable 19.30 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              636
  Free PE               0
  Allocated PE          636
  PV UUID               QA2yD3-U05c-ZIGG-tcdD-ayBJ-sikC-zj7S9e

and there lies the problem. Nothing has changed, the PV Size should be approx 30GB not 20GB, so why can't it resize to the new space available? Is it something to do with the fact that I have 0 Free Physical Extents available?
 
Old 12-24-2009, 03:09 AM   #7
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
OK, so I deleted one of LVs and then resized the PV

Code:
 pvresize -v /dev/sda2
    Using physical volume(s) on command line
    Archiving volume group "rootvg" metadata (seqno 16).
    No change to size of physical volume /dev/sda2.
    Resizing volume "/dev/sda2" to 41720421 sectors.
    Updating physical volume "/dev/sda2"
    Creating volume group backup "/etc/lvm/backup/rootvg" (seqno 17).
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
So in this case something has definitely been resized, and now we can see;

Code:
pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rootvg
  PV Size               19.89 GB / not usable 19.30 MB
  Allocatable           yes
  PE Size (KByte)       32768
  Total PE              636
  Free PE               96
  Allocated PE          540
  PV UUID               QA2yD3-U05c-ZIGG-tcdD-ayBJ-sikC-zj7S9e
Allocatable is now set to 'yes', not 'yes (but full)' as it was and looking at the VG;

Code:
vgdisplay
  --- Volume group ---
  VG Name               rootvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  18
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                5
  Open LV               5
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.88 GB
  PE Size               32.00 MB
  Total PE              636
  Alloc PE / Size       540 / 16.88 GB
  Free  PE / Size       96 / 3.00 GB
  VG UUID               rWAxdp-PEki-WQko-eLK9-OX5M-jRny-QHsDpN
The only space is available is the space I've made available by deleting the LV. It's driving me mad! There is an extra 10GB available on the device, but LVM can't see it!
 
Old 12-24-2009, 04:07 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,500

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
There have been murmurings in the past about vgresize - doesn't seem to be in the "standard" LVM2 command set.
Set the PV back and create a new PV and add that to the VG. Then all should come out in the wash.

(not a LVM user BTW - for a truckload of reasons - just musing aloud).
 
Old 12-24-2009, 04:33 AM   #9
ongte
Member
 
Registered: Jun 2009
Location: Penang, Malaysia
Distribution: Mandriva, CentOS, Ubuntu
Posts: 456

Rep: Reputation: 69
syg00 is right, you don't normally resize PVs, instead, you should use fdisk to create another partition (sda3) taking up the extra 10Gig and changed it's partition ID to 8e (for LVM).

Then you run:
Code:
# pvcreate /dev/sda3
# vgextend rootvg /dev/sda3
To extend the LV:
Code:
# lvextend -L +10G /dev/rootvg/rootlv
Finally resize the filesystem in the LV:
Code:
# resize2fs -p /dev/rootvg/rootlv
 
Old 12-24-2009, 04:40 AM   #10
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
There have been murmurings in the past about vgresize - doesn't seem to be in the "standard" LVM2 command set.
Set the PV back and create a new PV and add that to the VG. Then all should come out in the wash.

(not a LVM user BTW - for a truckload of reasons - just musing aloud).
It looks like you're right about vgresize not being in LVM2 (http://sources.redhat.com/cgi-bin/cv...n&cvsroot=lvm2)

What do you mean about "Set the PV back and create a new PV and add that to the VG"? Do you mean set the size of the disc back to 20GB in VSphere, rescan the device in Linux so it can only see 20GB and not 30GB and then create a new 10GB Virtual Disc in VSphere which will appear that as a new device in Linux and add that to the VG?
 
Old 12-24-2009, 07:49 AM   #11
jeg1972
LQ Newbie
 
Registered: Nov 2009
Location: Gateshead, UK
Distribution: Oracle Enterprise Linux
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ongte View Post
syg00 is right, you don't normally resize PVs, instead, you should use fdisk to create another partition (sda3) taking up the extra 10Gig and changed it's partition ID to 8e (for LVM).

Then you run:
Code:
# pvcreate /dev/sda3
# vgextend rootvg /dev/sda3
To extend the LV:
Code:
# lvextend -L +10G /dev/rootvg/rootlv
Finally resize the filesystem in the LV:
Code:
# resize2fs -p /dev/rootvg/rootlv
Thanks, I'll have a go at this... but this leaves a question regarding how useful thin provisioning is in VSphere. It's supposed to allow you to resize the disc on the fly, I could just create another another virtual disc and mount that... one for the VMWare forum I guess. Anyway, thanks for all of your help everyone!

Cheers

John
 
Old 01-01-2010, 10:11 PM   #12
twk
Member
 
Registered: Feb 2002
Location: Canada
Distribution: Fedora/RHEL
Posts: 152

Rep: Reputation: 31
I think once you run pvresize, you will need to reboot and server will pick up the new PV size.

However, normally on a VM (hosted by ESX), I simply add another disk to the VM - run rescan-scsi-bus.sh so it's visible to the VM, make it a PV then add it to the VG (vgextend). Finally I resize the LV (lvextend/resize2fs - RHEL5). This way there's no reboot involved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM Partition Resizing ChairmanMeoww Fedora 6 06-16-2012 07:00 AM
Resizing the LVM g_kapoor85 Linux - Software 3 03-21-2009 02:27 AM
Resizing an LVM partition oogs Fedora 5 10-24-2008 09:52 PM
resizing non-LVM partition laggerific Linux - Software 1 11-09-2006 07:20 PM
Resizing / with LVM zivota Red Hat 2 07-12-2006 04:30 PM


All times are GMT -5. The time now is 12:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration