LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to extend volume group size over the remaining space (http://www.linuxquestions.org/questions/linux-software-2/how-to-extend-volume-group-size-over-the-remaining-space-798448/)

scrat75 03-28-2010 11:38 AM

how to extend volume group size over the remaining space
 
Hi to all,

after goggling around and looking for in the linux Questions unsuccesfully, I'm here to ask you the way to extend the size of a LVM2 volume group over the remaining free space available on a physical volume.

My linux box is a Ubuntu Karmic 9.10 64bit, the 60GB hard disk has 2 win partition for about 19GB, a 1.5GB ext3 boot partition and finally a 36GB LVM partition (/dev/sda4) on which I created a volume group (volgrp) smaller 10GB than the 36GB physical volume (/dev/sda4).
What I want now is to extend the size of volume group up to the end of physical volume.

I tried to use the "vgextend volgrp /dev/sda4" but system answers me
with following output:

me@pc:~> sudo vgextend volgrp /dev/sda4
Physical volume '/dev/sda4' is already in volume group 'volgrp'
Unable to add physical volume '/dev/sda4' to volume group 'volgrp'.

Here the output of fdisk command:

me@pc:~> sudo fdisk -l

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x5ea4f703

Device Boot Start End Blocks Id System
/dev/sda1 1 637 5116671 1b Hidden W95 FAT32
/dev/sda2 * 638 2465 14683410 c W95 FAT32 (LBA)
/dev/sda3 2466 2596 1052257+ 83 Linux
/dev/sda4 2597 7296 37752750 8e Linux LVM

Should I use the pvmove command?

Thaks in advance for your help.

chrism01 03-29-2010 12:56 AM

Are you saying that you used a pvcreate on sda4 that is less than the available size? If so, you could just use pvresize to expand it http://linux.die.net/man/8/pvresize. See also http://linux.die.net/man/8/vgchange.

Exactly what cmds did you use to create this?

OTOH, it may well be simpler to backup and re-create the pv/vg/lv. You should do a backup anyway before even trying to amend this.

scrat75 03-29-2010 03:31 PM

Hi Chrism01,

I try to respond to your question posting you the output of these lvm commands:

ubuntu@ubuntu:~$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda4
VG Name volgrp
PV Size 36.00 GB / not usable 3.73 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 9216
Free PE 2560
Allocated PE 6656
PV UUID CWp5JY-X0VN-20WD-hTL9-u1mG-smT5-SAHTxX

So I'm quite sure that when I created the physical volume with pvcreate command (pvcreate /dev/sda4) I used for it the whole size of sda4 partition.

I also post you the output of vgdisplay:

ubuntu@ubuntu:~$ sudo vgdisplay
--- Volume group ---
VG Name volgrp
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 7
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 36.00 GB
PE Size 4.00 MB
Total PE 9216
Alloc PE / Size 6656 / 26.00 GB
Free PE / Size 2560 / 10.00 GB
VG UUID YS9zRl-I3Zx-yLdL-0VXI-h5pu-XlEl-YWWtkH

As you can see, the size of allocated PEs is 26.00 GB, instead the size of free PE is 10.00 GB.
What I want is to recover the 10GB free PE and to assign them finally to the volume group "volgrp".

Should I perhaps use the lvextend command?

Thanks in advance for your suggestions,

scrat75

scrat75 03-29-2010 03:51 PM

Hi Chrism01,

with the following command I increased the logical volume "usr" size of 2GB.

ubuntu@ubuntu:~$ sudo lvextend -L +2G /dev/volgrp/usr /dev/sda4
Extending logical volume usr to 8.00 GB
Logical volume usr successfully resized

I ran vgscan command and then vgdiplay:

ubuntu@ubuntu:~$ sudo vgdisplay
--- Volume group ---
VG Name volgrp
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 12
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 7
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 36.00 GB
PE Size 4.00 MB
Total PE 9216
Alloc PE / Size 7168 / 28.00 GB
Free PE / Size 2048 / 8.00 GB
VG UUID YS9zRl-I3Zx-yLdL-0VXI-h5pu-XlEl-YWWtkH

As you can see, now the free PE space is 8GB, before was 10GB.

Now I restart to see if all things are good..

Scrat75


All times are GMT -5. The time now is 09:17 PM.